aspose file tools*
The moose likes Beginning Java and the fly likes Do I need to add CLASSPATH/PATH to run java codes in a script ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Do I need to add CLASSPATH/PATH to run java codes in a script ?" Watch "Do I need to add CLASSPATH/PATH to run java codes in a script ?" New topic
Author

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

Steve Yu
Ranch Hand

Joined: Mar 26, 2003
Posts: 60
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

Joined: Aug 20, 2001
Posts: 1824

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.


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Do I need to add CLASSPATH/PATH to run java codes in a script ?