Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Eclipse and Runable Jar work but java.exe does not(How to diagnose Class Not Found?)
Eclipse and Runable Jar work but java.exe does not [message #877531] Sun, 27 May 2012 00:13 Go to next message
Jeff Graham is currently offline Jeff GrahamFriend
Messages: 2
Registered: May 2012
Junior Member
I have an Eclipse project that runs OK. The runnable jar file create runs OK. However if I do a command line call specifying the jar file in the -classpath and the main class name, I get a ClassNotFoundException for one of the included classes, not the main class. Then the final error is "Could not find the main class: MinTest".

My command line:
java -cp ..\bin;.\JavaVF_run.jar MinTest

The result:
Exception in thread "main" java.lang.NoClassDefFoundError: com/neurotec/devices/NDeviceType
Cause by: .......
Could not find the main class: MinTest Program will exit.

If my command line is:
java JavaVF_run.jar
I get the same error.

If my command line is:
JavaVF_run.jar
It works!

What am I doing wrong in the first two cases? What is the difference?



Re: Eclipse and Runable Jar work but java.exe does not [message #885585 is a reply to message #877531] Wed, 13 June 2012 09:33 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
On 27.05.2012 02:13, Jeff Graham wrote:
> I have an Eclipse project that runs OK. The runnable jar file create
> runs OK. However if I do a command line call specifying the jar file
> in the -classpath and the main class name, I get a
> ClassNotFoundException for one of the included classes, not the main
> class. Then the final error is "Could not find the main class: MinTest".
>
> My command line:
> java -cp ..\bin;.\JavaVF_run.jar MinTest
>
> The result:
> Exception in thread "main" java.lang.NoClassDefFoundError:
> com/neurotec/devices/NDeviceType
> Cause by: .......
> Could not find the main class: MinTest Program will exit.
>
> If my command line is:
> java JavaVF_run.jar
> I get the same error.
>
> If my command line is:
> JavaVF_run.jar
> It works!
>
> What am I doing wrong in the first two cases? What is the difference?
I suspect that you packaged other JARs into your runnable JAR. In that
case a special class loader (from Eclipse) is needed and hence you need
to run it using
java -jar the.jar

Dani
>
>
>
>
Re: Eclipse and Runable Jar work but java.exe does not [message #885765 is a reply to message #885585] Wed, 13 June 2012 14:48 Go to previous message
Jeff Graham is currently offline Jeff GrahamFriend
Messages: 2
Registered: May 2012
Junior Member
Thanks, that is the problem. It was resolved by specifying additional jars in the command line.
Previous Topic:Eclipse problems~~~
Next Topic:Which package do I need
Goto Forum:
  


Current Time: Fri Apr 26 18:49:12 GMT 2024

Powered by FUDForum. Page generated in 0.08143 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top