Eclipse Java9 Export Runnable JAR File

I am trying to configure Eclipse on Java 9, but the Export → Runnable JAR file does not work, since it cannot find the main method.

Context:

  • Windows 10

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

  • JDK 9.0.1 and JRE 9.0.1 are installed and configured in Eclipse

What I've done:

  • File -> New Java Project

Create a New Java Project

  • Click Finish

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

Edited Main.java to the 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 the Runnable JAR: Right-click on Project → Export → Runnable JAR file

Error message

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

The main class is defined in startup configurations


In Java 8, there was no problem exporting jar by following the steps above.

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

+5
source share
1 answer

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

+3
source

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


All Articles