Skip to main content
10-Marble
March 8, 2023
Question

extension

  • March 8, 2023
  • 2 replies
  • 933 views

Below line of  code has been written in thingworx java extension in eclipse

InputStream in=TestThingShape.class.getResourceAsStream("test.xlsx");  

 

Where does the file test.xlsx is present in Thingworx server?

 

Please help me over here.

 

2 replies

17-Peridot
March 8, 2023

check out in following path, if it is windows..

 

C:\Program Files (x86)\ThingWorxFoundation\tomcat\apache-tomcat-9.0.62\test.xslx

Also refer following post..

https://community.ptc.com/t5/ThingWorx-Developers/Thingworx-java-extension/m-p/857179#M61298

https://community.ptc.com/t5/ThingWorx-Developers/Thingworx-extension-java/m-p/858158#M61345

 

18-Opal
March 8, 2023

The response is a bit more complex than that. Class#getResourceAsStream allows you to access files on the Java classpath, i.e. embedded inside the JARs. Your test.xlsx should be packaged in the same JAR as your TestThingShape, side-by-side with TestThingShape.class file. The JAR is then zipped together with metadata.xml to produce the extension bundle.

 

Details: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Class.html#getResourceAsStream(java.lang.String)