jQuery in Action, 2nd edition*
The moose likes Java in General and the fly likes can run on eclispe but not command line Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "can run on eclispe but not command line" Watch "can run on eclispe but not command line" New topic
Author

can run on eclispe but not command line

Kee Kee moon
Ranch Hand

Joined: Dec 11, 2009
Posts: 147

I can run the program on eclipse, but could not run on console window command line.
Please help. Please see the error below. myapps/encryptin/Encrypt is in a jar file and I have added into library on eclipse.
After compiling, I can run on eclipse, but failed on command line.

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: myapps/encryption/Encrypt

Thanks
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38033
    
  22
Kee Kee moon wrote:
I can run the program on eclipse, but could not run on console window command line.
Please help. Please see the error below. myapps/encryptin/Encrypt is in a jar file and I have added into library on eclipse.
After compiling, I can run on eclipse, but failed on command line.

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: myapps/encryption/Encrypt

Thanks
And how did you add the jar file to the classpath when you ran the program from the command line? Is there a classpath in the manifest file?
Kee Kee moon
Ranch Hand

Joined: Dec 11, 2009
Posts: 147
Campbell Ritchie wrote:
Kee Kee moon wrote:
I can run the program on eclipse, but could not run on console window command line.
Please help. Please see the error below. myapps/encryptin/Encrypt is in a jar file and I have added into library on eclipse.
After compiling, I can run on eclipse, but failed on command line.

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: myapps/encryption/Encrypt

Thanks
And how did you add the jar file to the classpath when you ran the program from the command line? Is there a classpath in the manifest file?



this is my MANIFEST.MF:

Manifest-Version: 1.0
Class-Path: . consoleServer\consoleServerApp.jar consoleServer\Login.jar consoleServer\misc.jar
Main-Class: consoleServer.consoleServerApp


consoleServer\consoleServerApp.jar consoleServer\Login.jar consoleServer\misc.jar are my programs.
I use eclipse to compile the programs that I coded, eclipse generate *.class and I jar the clesses as above.

Please help.


Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 498

Kee Kee moon wrote:
this is my MANIFEST.MF:

Manifest-Version: 1.0
Class-Path: . consoleServer\consoleServerApp.jar consoleServer\Login.jar consoleServer\misc.jar
Main-Class: consoleServer.consoleServerApp


consoleServer\consoleServerApp.jar consoleServer\Login.jar consoleServer\misc.jar are my programs.
I use eclipse to compile the programs that I coded, eclipse generate *.class and I jar the clesses as above.

Please help.




Check if the jar files are relative to the main Jar file.


PM Me If You Want to get Urgent Help on Java Programming
Kee Kee moon
Ranch Hand

Joined: Dec 11, 2009
Posts: 147
Nam Bill wrote:
Kee Kee moon wrote:
this is my MANIFEST.MF:

Manifest-Version: 1.0
Class-Path: . consoleServer\consoleServerApp.jar consoleServer\Login.jar consoleServer\misc.jar
Main-Class: consoleServer.consoleServerApp


consoleServer\consoleServerApp.jar consoleServer\Login.jar consoleServer\misc.jar are my programs.
I use eclipse to compile the programs that I coded, eclipse generate *.class and I jar the clesses as above.

Please help.




Check if the jar files are relative to the main Jar file.


What does it mean?? which jar file is related to which one. Thank you for your help.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38033
    
  22
Not related, relative. That is about the file path.
Kee Kee moon
Ranch Hand

Joined: Dec 11, 2009
Posts: 147
Campbell Ritchie wrote:Not related, relative. That is about the file path.


How to resolve the issue?

Thanks a lot.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38033
    
  22
What is the path to the jar you are looking for and what is the path to your jar you are executing?
Kee Kee moon
Ranch Hand

Joined: Dec 11, 2009
Posts: 147
Campbell Ritchie wrote:What is the path to the jar you are looking for and what is the path to your jar you are executing?


my executing jar is in C:\apps\workspace\myapp\bin\myapp.jar

my others jar files are in c:\apps\jars\xxx .....

I can run the application on eclipse, it works prefect, but I can the archive into one jar file to delivery my project.
I get error as Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError:.. when I run:

java -jar myapp.jar

please help. Thanks
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

i may be off base here, but can't you just copy the other files to C:\apps\workspace\myapp\bin\myapp.jar
that should make it easier


SCJP
Visit my download page
Kee Kee moon
Ranch Hand

Joined: Dec 11, 2009
Posts: 147
Randall Twede wrote:i may be off base here, but can't you just copy the other files to C:\apps\workspace\myapp\bin\myapp.jar
that should make it easier




What do you mean copy the other files to myapp.jar ??

Thanks a lot.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

oops, my bad. i meant copy them to the bin folder(to the same folder as myapp.jar).
Kee Kee moon
Ranch Hand

Joined: Dec 11, 2009
Posts: 147
Randall Twede wrote:oops, my bad. i meant copy them to the bin folder(to the same folder as myapp.jar).


Yes, I did that, but it will come up another java.lang.NoClassDefFoundError, then another.....


please help thanks.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

do you have any package statements? that can cause "problems" like this. just trying to help, i haven't used jar very much.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

i'm so sorry i can't help. i plan to learn more about jar and manifest files soon, but too late to help you i imagine. at least my post moves your thread to the top of the forum again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can run on eclispe but not command line
 
Similar Threads
How to run a java class from command line in eclipse
Couldn't Start Tomcat in Win2K- SOS
Problem with mvn archetype using Eclipse plugin
Trouble restarting Tomcat 6.0.30 with Eclipse
java app launch on console