Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse Java9 Export Runnable JAR file [duplicate]

I am trying to setup Eclipse with Java 9 but the Export -> Runnable JAR file is not working since it can't find the main method.

Context:

  • Windows 10

  • Eclipse IDE version Oxygen 1a Release (4.7.1a) Build: 20171005-1200

  • JDK 9.0.1 and JRE 9.0.1 installed & setup in Eclipse

What I did:

  • File -> New Java Project

Create New Java Project

  • Click on "Finish"

  • Right click on src -> New -> Class Add new class

Edited Main.java to following code:

package com.application;

public class Main {

  public static void main(String[] args) {
    System.out.println(System.getProperty("java.version"));
  }
}

Run -> No errors.

Console log result: "9.0.1"


Now I want to export the code to a Runnable JAR: Right click on the Project -> Export -> Runnable JAR file

Error message

So I went to the Run Configurations but the Main class is defined:

Main class is defined in the run configurations


With Java 8 there was no problem exporting the jar following the steps above.

What do I have to do, to use the "export to Runnable JAR file" in Java 9?

like image 306
Peter Winzer Avatar asked Nov 01 '17 12:11

Peter Winzer


1 Answers

I had the same problem and I used the export "Jar file" option, not the "Runnable Jar file". jar file option Then I selected the options as shown below. options1 options2 At the final step I selected a main class to make my jar runnable. final configuration By clicking "Browse" you get the available main classes.

like image 119
Zerthimon Avatar answered Oct 04 '22 22:10

Zerthimon