I have following command that runs on Windows:
java -classpath lib/prov-jdk14-132.jar;../EncUtility com.xxxx.projects.disc.bowl.FileChooseApp
Now I am using nano command to make executable with following command in OS X:
java -classpath ../EncUtility/lib/prov-jdk14-132.jar:../EncUtility com.xxxx.projects.disc.bowl.FileChooseApp
This command runs perfectly in a terminal but when I use nano command to make utility then it shows the following error:
cp_mac1$ /Users/cp_mac1/Desktop/EncUtility/start ; exit;
Exception in thread "main" java.lang.NoClassDefFoundError: com/xxxx/projects/disc/bowl/FileChooseApp
Caused by: java.lang.ClassNotFoundException: com.xxxx.projects.disc.bowl.FileChooseApp
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
logout
[Process completed]
I have figure out that it uses extra /start in path. But i am not able to solve it even using cd ..
Your script is being run in a different folder than where it is stored…
The current working directory, when you start your script, is not the location of the script, it’s whatever folder you happened to be in when you ran it.
Try using the snippet from Getting the source directory of a Bash script from within to set the working directory, from which your paths should be relative: e.g.
The preamble does various shell magics to resolve where the script actually is stored. The
cdthen changes the working directory to the folder containing that, and theexecis just for a tiny efficiency: it replaces your script’s executable process with the Java VM, rather than starting it as a child process. (Note that nothing beyond theexecwould run in your script.)