• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can run on eclispe but not command line

 
Kee Kee moon
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 502
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Kee Kee moon
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not related, relative. That is about the file path.
 
Kee Kee moon
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Not related, relative. That is about the file path.


How to resolve the issue?

Thanks a lot.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4439
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Kee Kee moon
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4439
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oops, my bad. i meant copy them to the bin folder(to the same folder as myapp.jar).
 
Kee Kee moon
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4439
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4439
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic