1
votes

I went to eclipse>export>java>runnable jar file

I changed launch configuration to my project name; destination: desktop.

I tried all three library handling options:

  1. extract required folders into generated JAR
  2. Package required libraries into generated JAR
  3. copy required files into a sub-folder next to the generated JAR.

I did not check anything to do with "ANT scripts".

When I pressed "finish" in the export window, eclipse gave me a error: "Could not find main method from given launch configuration". After pressing the "finish" button in the eclipse export window, the next button was grayed out. It created a JAR file at the destination. When I tried to open it Mac's Jar Launcher (default)(13.5.0), it gave me the message:

The Java JAR file "filename.jar" could not be launched.

Check the Console for possible error messages.

I googled this and some people said to check the manifest.mf file. I extracted it, then: "META-INF>manifest.mf". I opened manifest.mf with textedit. Inside manifest.mf were the lines:

Manifest-Version: 1.0

Rsrc-Class-Path: ./ acm.jar

Class-Path: .

I am running Mac OSx 10.6.8 snow leopard. I have the latest java available for snow leopard (I think my java is the one just BEFORE java 7).

Also, I'm trying to export a project with:

  1. a .java file that contains all my code
  2. acm.jar
  3. java.policy.applet
  4. Scores.txt

My .java file contains a public void run() {} and JFrames/JPanels. My .java file extends ConsoleProgram.

1

1 Answers

2
votes

If there's no public static void main(String[] args) method, the virtual machine (Java) will not know where to start your program. It sounds like your run() method is what you want to start your program. If so, then add (to your main class (.java)) a method: public static void main(String[] args). Re-export your .jar, making sure the launch configuration is set to your Project name, and your main class.