0

So I have Test.jar. It's directories look like:

META-INF/MANIFEST.MF
Test/src/test/Test.java
             /MainFrame.java
             /MainPanel.java
             /image.png

And my mainfest file looks like:

Manifest-Version: 1.0
Created-By: 1.7.0_13 (Oracle Corporation)
Main-Class: test.Test

When launching from command line (java -jar Test.jar) i get such error: could not find or load main class test.Test. How to solve it? I know it's problem with Main-Class line in manifest but I dont know how should path look like..

user2102972
  • 251
  • 2
  • 6
  • 13
  • A jar file is supposed to contain compiled class files. Not java source files. Read [the tutorial](http://docs.oracle.com/javase/tutorial/deployment/jar/). – JB Nizet Feb 23 '13 at 18:58

1 Answers1

2

thats because your jar apparently contains java source files and not compiled java class files. your jar layout should be

META-INF/MANIFEST.MF
/test/Test.class
     /MainFrame.class
     /MainPanel.class
     /image.png

your manifest is fine. you should compile your source code files (*.java) to produce *.class files and package those into your jar.

radai
  • 23,949
  • 10
  • 71
  • 115
  • Thanks! And now - what should I do to run this jar with double-clicking JAR file? I can run it from command line now but Id like to run it like exe files. Because now, when I double-click JAR file it opens and shows its directories. I want application to start when double-cliking JAR file. Is it possible with JAR files? – user2102972 Feb 23 '13 at 19:06
  • @user2102972 - see the answers to this question - http://stackoverflow.com/questions/394616/running-jar-file-in-windows – radai Feb 23 '13 at 19:07