My website is hosted on Apache on ubuntu. I have been given a JAR file which has two folders inside it and some .class and .scc files. Lets say jar file name = myJarfile, folder inside this archive = myFolder, and Class inside this folder is = myClass.
I have been told to run the class like this:
java myFolder.myClass
but i get this error:
$ java myFolder.myClass
Exception in thread "main" java.lang.NoClassDefFoundError: myFolder/myClass
Caused by: java.lang.ClassNotFoundException: esGateKeeper.cookieServer
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:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: myFolder/myClass. Program will exit.
I also tried:
$ java myJarfile.myFolder.myClass
Exception in thread "main" java.lang.NoClassDefFoundError: myJarfile/myFolder/myClass
Caused by: java.lang.ClassNotFoundException: myJarfile.myFolder.myClass
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:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: myJarfile.myFolder.myClass. Program will exit.
Admin told me it is CLASSPATH issue. I have no idea. My website uses PERL CGI and no JAVA at all. I am not JAVA programmer, and googling did not give me idea how to get this running.
the Class/or JAR file is supposed to start an IPC daemon on my localhost which i would communicate with from my PERL CGI, for authentication purposes. It decrypts the cookie I get from browser.
I am not sure what I will need to install on my server for this to run. I have java as below:
$ java -version
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot(TM) Client VM (build 17.0-b16, mixed mode, sharing)
Pl advice.
ty. Rajeev
_OK__ I resolved this by exporting a CLASSPATH variable pointing to the .jar file:
export CLASSPATH="/full/path/to/myJarfile.jar"
then executes fine:
$ java myFolder.myClass
starts the daemon....
But to be honest, I have no idea what is going on here. This .jar file has two folders in it: myFolder and a META-INF. myFolder has bunch of .class files and one .scc file. none of them is named "main"....
I appreciate the time and help extended to me.
ty. Rajeev