Skip to main content
6-Contributor
July 24, 2024
Question

Help compiling java files with bash script

  • July 24, 2024
  • 2 replies
  • 2335 views

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.

2 replies

20-Turquoise
July 24, 2024

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`

loganc6-ContributorAuthor
6-Contributor
July 24, 2024

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 II
22-Sapphire II
July 25, 2024

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

Community Moderator
August 7, 2024

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