• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can't run a program in a jar file  RSS feed

 
rick sowfilk
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there,

i have the following code in C:\test_app\main_code.java


i compile like that
C:\test_app>javac main_code.java
C:\test_app>

and the i use jar to pack the class file
C:\test_app>jar cfe myFile.jar test_app.main_code main_code.class
C:\test_app>


but when i try to run the code
C:\test_app>java -jar myFile.jar
Error: Could not find or load main class test_app.main_code
C:\test_app>
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try running it without the jar?

 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess would be that the directory hierarchy is not correct in the jar file. Make sure that the main_code.class file is inside of a "test_app" directory. Yuu can check the contents of the jar file by "jar tf myFile.jar".
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!