Do I need to add CLASSPATH/PATH to run java codes in a script ?
Joined: Mar 26, 2003
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 ?
Joined: Aug 20, 2001
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.