Skip to main content
10-Marble
Apr 15, 2022 9:35 PM UTC
Solved

Using Apache POI with Java OTK for Creo

Hello,

I'm trying to use Apache POI to export some data to Excel in conjunction with an existing customization written with Java OTK. I'm using Eclipse on Windows. The project builds fine and loads in Creo, but it throws an exception when it gets to the first line of code that uses Apache POI. It says it's unable to find the class. Any thoughts would be greatly appreciated.

Thanks,

-Russ

20-Turquoise
Apr 22, 2022 9:27 PM UTC

@Rmorin wrote:

Thanks, Randy. I'm still not having any luck. I tried manually setting the CLASSPATH as you mention within the system window loaded from Creo.

Setting it in the system window, opened from Creo Parametric, will not affect Creo Parametric. You have to set it before starting Creo Parametric and then view the results of that in the Creo Parametric system window.

 

I echo it back and confirm that the correct JAR file is shown in addition to the otk.jar file, but it still can't find the class. Agreed that getting the CLASSPATH right can be a pain for Java in general, but this seems to be Creo specific. I sent a simplified version of my code off to PTC to see if they can figure it out.

Thanks,

-Russ


 

12 replies

20-Turquoise
Apr 15, 2022 9:52 PM UTC

Could be several issues however most likely is incorrect CLASSPATH setting. Probably missing the apache poi jar in the Creo Parametric class path.

See https://www.ptc.com/en/support/article/CS000309245

Translate
Rmorin10-MarbleAuthor
10-Marble
Apr 20, 2022 3:51 AM UTC

Randy, what you're saying makes sense, but I'm still having trouble getting things to work. From your explanation, I now understand why my JAR builds correctly. because the Build Path is set properly in Eclipse. I just tried using config.pro add_java_class_path command, but I'm still not having any luck. Do you know if this can be set to a folder with a wildcard or if it must be set to a specific JAR? 

Thanks,

-Russ

Translate
Rmorin10-MarbleAuthor
10-Marble
Apr 20, 2022 7:58 PM UTC

Randy, I did try adding the external JARs to the classpath via all three methods described in that support article (https://www.ptc.com/en/support/article/CS000309245), but I'm still stuck with a class not found error. 

Translate
15-Moonstone
Apr 19, 2022 3:54 AM UTC

what build tool do you use ? .. how is your app deployed (as single or multiple jar files or not packed class files) ?

Translate