• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Running Orion (java -jar orion.jar)

 
Ranch Hand
Posts: 161
Firefox Browser Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 161
Firefox Browser Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I installed JRE6 again and both javac.exe and java.exe are working.

Thanks for the pointer.

Gary
 
this is supposed to be a surprise, but it smells like a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic