Creating a jar file - does not work on other computers

I am trying to pack my program in a JAR file so that it can be used on multiple computers.

My program consists of start.java , writer.java and writer.java .

A program written in Eclipse works fine on my computer. When exporting, it will work on my computer, but the following error will occur on other computers:

"Could not find the main class: start. Program will exit".

Again, my program works fine on my computer when I double-click on it.

I tried to create a JAR file through the command line, and my manifest file is correct. What's happening?

+6
source share
2 answers

This is a very strange error that I encountered.

Assuming you are using JRE 1.7 ,
The only fix I found for this problem was to change the JRE project version from 1.7 to 1.6 .

Edit: I also encountered this error on computers with JVM 7.

+5
source

I believe this is because you are trying to specify a class file from the default package for the Main-Class attribute. JAR files and default packages do not mix well. I would advise you to include the entire project in a simple package (as far as I saw from the attached JAR file, which you use only by default).

Also, try moving on to the general Java conventions (it's hard to say what a class is, and at first I thought there were some packages, a specific error, i.e. use Start instead of Start as the class name).

Another common problem is that the last line of the MANIFEST.MF file is not interpreted as stated in the Java tutorial :

Attention:

The text file must end with a new line or carriage return. The last line will not be parsed correctly if it does not end with a new line or carriage return.

0
source

Source: https://habr.com/ru/post/908339/


All Articles