cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Help compiling java files with bash script

loganc
6-Contributor

Help compiling java files with bash script

Version: Windchill 12.0

 

Use Case: Need help completing my bash script to compile java files. Currently having issues with windchill class not found exceptions, I believe I need to include the .JAR files into the classpath, but am not sure how to do so.


Description:

Here is what I have written so far, the javac $file command is leading to class not found exceptions since I haven't included the JAR files: 

loganc_1-1721830498807.png

 

I saw this article that briefly talked about how to do https://www.ptc.com/en/support/article/CS324171

 

But I am using more than one jar file, probably about 50 in total. Need help figuring out what to do with them.

6 REPLIES 6
RandyJones
19-Tanzanite
(To:loganc)

You might need to setup the Windchill shell environment inside the bash script. I add these 2 following lines to shell scripts that need it:

echo " Setting up the Windchill shell environment"

eval `/opt/ptc/Windchill/Windchill/bin/windchill --java=/opt/ptc/Windchill/Java/bin/java eval`

loganc
6-Contributor
(To:RandyJones)

I added in the line to setup Windchill shell environment, but am still getting class not found exceptions when compiling. I tried adding my jar files to the classpath when compiling, which is when I noticed that each file was separated by a string, when they should have been separated by a colon. 

After putting all the the jar file paths into a string variable (separating them by a colon) I'm still getting Windchill class not found errors. 

 

Here's what my jar_files_str variable looks like: (full paths of jar files separated by ':') 

loganc_0-1721851264552.png

 

Current bash file:

loganc_1-1721851347984.png

 

errors still getting compiling:

loganc_2-1721851848756.png

 

 

HelesicPetr
22-Sapphire I
(To:loganc)

Hi @loganc 

You should add all class to the variable not just jar files.

There is a folder codebase in the Windchill folder, where all the internal classes are.

 

So you should add the WTHOME\codebase folder to the java class variable

 

PetrH

loganc
6-Contributor
(To:HelesicPetr)

I'm close to solving this, but not quite. I was able to add the OOTB classes to my classpath with this: CLASSPATH=/pdmlink/ptc/installers/wc12_codebase/wc12_codebase:/pdmlink/ptc/build/jars/*, the issue is I also need custom classes to be referenced in the classpath as well. I tried setting the classpath /pdmlink/ptc/build/jars:/pdmlink/ptc/installers/wc12_codebase/wc12_codebase:/pdmlink/ptc/installers/custom/customization, with the custom class files being in customization. This did not work. I also tried making a copy of wc12_codebase, and copying the classfiles to there, so classpath=/pdmlink/ptc/installers/wc12_codebase_copy/wc12_codebase:/pdmlink/ptc/build/jars/* This too did not work. RenumberResult.class exists in the custom/customization directory, So I am unsure why the compiler isn't able to recognize this.

 

loganc_0-1723132007199.png

 

HelesicPetr
22-Sapphire I
(To:loganc)

Hi @anursingh 

It is easier to use IDE to compile the customization where you can see what is really missing..

In your case you have still problem with the path and custom classes that are missing in the definition somehow,. 

PetrH

Hi @loganc,

 

I wanted to follow up with you on your post to see if your question has been answered. 
If so, please mark the appropriate reply as the Accepted Solution. 
Of course, if you have more to share on your issue, please let the Community know so that we can continue to help you. 

 

Thanks,
Anurag
 

Announcements

Top Tags