• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Once again: Creating a jar-file

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
CLASS-PATH should be Class-Path.
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
I don't always make ads but when I do they're tiny
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic