aspose file tools*
The moose likes Cattle Drive and the fly likes Running Orion (java -jar orion.jar) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Running Orion (java -jar orion.jar)" Watch "Running Orion (java -jar orion.jar)" New topic
Author

Running Orion (java -jar orion.jar)

Gary Ba
Ranch Hand

Joined: Oct 23, 2009
Posts: 161

Hi guys,
I am getting back into the cattle drive assignment where I had left off on Servlets (Reverse-2). I tried running orion using java -jar orion.jar but received an error..

C:\orion>java -jar orion.jar
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object

I looked up what the error is and it told met that my ClassPath is not correct. I then tried javac if I can compile any of my old java program and it gave me a similar error.
I typed PATH on my command line and it gave me...

C:\orion>path
PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32
\WindowsPowerShell\v1.0\;C:\Program Files\jEdit;C:\Program Files\Java\jdk1.6.0_2
5\bin\bin;C:\Program Files\QuickTime\QTSystem\

Sure enough my classpath has an extra ...\bin at the end. Removed it and is able to compile using javac . However, java -jar orion.jar is still giving me a problem.
I then read online that I can type the whole path..."C:\Program Files\Java\jdk1.6.0_25\bin\java.exe" -jar orion.jar. And boom it worked which tells me jdk is working fine.

Question: Why is it that my javac is working without specifying the whole path while java does not?
What am I missing here. To me, my classpath is setup correctly and jdk is working fine.

Let me know if I need to explain more.

Thank you in advance.

Gary


star chaser..
Stuart A. Burkett
Ranch Hand

Joined: May 30, 2012
Posts: 679
Gary Ba wrote:C:\orion>java -jar orion.jar
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object

I looked up what the error is and it told met that my ClassPath is not correct. I then tried javac if I can compile any of my old java program and it gave me a similar error.


I'm willing to bet that it actually gave you a completely different error. Probably something like
'javac' is not recognized as an internal or external command, operable program or batch file.

Gary Ba wrote:I typed PATH on my command line and it gave me...

C:\orion>path
PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32
\WindowsPowerShell\v1.0\;C:\Program Files\jEdit;C:\Program Files\Java\jdk1.6.0_2
5\bin\bin;C:\Program Files\QuickTime\QTSystem\

Sure enough my classpath has an extra ...\bin at the end.


PATH and CLASSPATH are not the same thing. PATH tells Windows where it can find commands when you type them on the command line. CLASSPATH tells java/javac where it can find any classes it requires.


Gary Ba wrote:I then read online that I can type the whole path..."C:\Program Files\Java\jdk1.6.0_25\bin\java.exe" -jar orion.jar. And boom it worked which tells me jdk is working fine.

Question: Why is it that my javac is working without specifying the whole path while java does not?

When you type just java or javac, Windows looks through all the directories specified in the PATH to try and find an executable of that name.
When you type javac it finds javac.exe in C:\Program Files\Java\jdk1.6.0_25\bin and executes it.
However when you type java it finds java.exe in either C:\Windows\system32 or C:\Windows (I can't remember which one) and this uses the registry to find which is the current JRE that you have installed. I suspect the fact that the error message says it can't find java/lang/Object means your JRE installation is corrupted. I would suggest uninstalling all the JREs on your system (not JDKs) and then reinstalling the latest version and see if that fixes the problem.
Gary Ba
Ranch Hand

Joined: Oct 23, 2009
Posts: 161

I installed JRE6 again and both javac.exe and java.exe are working.

Thanks for the pointer.

Gary
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Running Orion (java -jar orion.jar)