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:
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
So I went to the Run Configurations but the Main class is defined:
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?
I had the same problem and I used the export "Jar file" option, not the "Runnable Jar file". Then I selected the options as shown below. At the final step I selected a main class to make my jar runnable. By clicking "Browse" you get the available main classes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With