Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Do I need to add CLASSPATH/PATH to run java codes in a script ?

 
Steve Yu
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to write a UNix script to run a java code written by a third party team. For example, I want to do "java MyApplication ..." in the script. Now my questions are --
1. do I need add "PATH" and/or CLASSPATH in the script and then export the PATH/CLASSPATH before I call "java MyApplication ..." ?
2. The "MyApplication" code uses some special API developed by the third party team and they have a special .jar file for that. So, do I need to add that in the CLASSPATH in my script ?
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
generally speaking, if java is properly installed on the system, then you do not need to add that to the path.
If you are trying to run a third party .jar file, yes, you do have to specify the CLASSPATH. If you don't want to mess with the system classpath, you can add the -classpath switch to the call to java e.g., java -classpath <your classpath here> YourApplication.
Just remember that the -classpath switch overrides the system CLASSPATH; it is not in addition to it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic