• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Once again: Creating a jar-file

 
Wolfgang Troescher
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

I´m desperating: For hours I´m trying to create a runnable JAR-File, but it doesn´t work. I´v already read a many about this topic in forums and books, but without success.

I create my JAR-file with following command-line:


The JAR-file is created and contains the desired Manifest-file:


Well.. seems everything is all right. But if I double-click on it: "Could not find the main class". But the Main-Class is all right!

If I try to start the programm with

the programm starts successfully!

Strange: Another program I wrote starts successfully by doubleclick on the generated JAR-file, which was created in nearly the same way....
Can you help me?

Thank you
Wolfgang
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15480
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add an empty line at the bottom of the manifest file, and see if it works then.

The tutorial warns about this:
Warning: The text file from which you are creating the manifest must end with a new line or carriage return. The last line will not be parsed properly if it does not end with a new line or carriage return.
 
Wolfgang Troescher
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:Add an empty line at the bottom of the manifest file, and see if it works then.

The tutorial warns about this:
Warning: The text file from which you are creating the manifest must end with a new line or carriage return. The last line will not be parsed properly if it does not end with a new line or carriage return.


An empty line is there! And I didn´t use Windows-Notepad, but Notepad++ to get right new-line-codes...

And: my manifest-file is properly included!
 
Wolfgang Troescher
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wolfgang Troescher wrote:
Jesper de Jong wrote:Add an empty line at the bottom of the manifest file, and see if it works then.

The tutorial warns about this:
Warning: The text file from which you are creating the manifest must end with a new line or carriage return. The last line will not be parsed properly if it does not end with a new line or carriage return.


An empty line is there! And I didn´t use Windows-Notepad, but Notepad++ to get right new-line-codes...

And: my manifest-file is properly included!


Problem solved: I removed the "dot" from the end of the line:



to


Now it works fine. But... I don´t know why...

No... it still DOESN´T WORK
Doubleclick on JAR started program, but just if the directories with class-files are there! If I remove them: doesn´t start...

Wolfgang
 
Rob Spoor
Sheriff
Pie
Posts: 20659
64
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CLASS-PATH should be Class-Path.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15480
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the 't' option of the jar command to see what the structure of the jar file is (what files and directories are in there).

What output exactly do you get when you type in a command like this: jar tvf InfoScreenManager.jar
 
Wolfgang Troescher
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:You can use the 't' option of the jar command to see what the structure of the jar file is (what files and directories are in there).

What output exactly do you get when you type in a command like this: jar tvf InfoScreenManager.jar


Hi!

I unzipped the jar-file to see what files are in it. It seems everything o.k.! The path-structure of the package is there with all .class-files in it, the META-INF-directory with MANIFEST.MF, containing correct hint to the main-class ("Main-Class: foo.bar.MyMainClass").

If I try to start programm by double-click on XP: Nothings happens. With Win7 error-message appears ("Could not find the main class"). Frustrating!!!
 
Rob Spoor
Sheriff
Pie
Posts: 20659
64
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
javaw.exe, the application used to launch JAR files, has rubbish error handling. Any Throwable thrown from the main method is displayed as that rubbish error message. Open a command prompt and run the JAR file as follows, and see what error message it actually prints out:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic