Skip to main content
10-Marble
April 15, 2022
Solved

Using Apache POI with Java OTK for Creo

  • April 15, 2022
  • 2 replies
  • 5321 views

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

Best answer by RandyJones

@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


 

2 replies

20-Turquoise
April 15, 2022

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

Rmorin10-MarbleAuthor
10-Marble
April 20, 2022

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

Rmorin10-MarbleAuthor
10-Marble
April 20, 2022

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. 

15-Moonstone
April 19, 2022

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