Build artifact in IntelliJ

Viewed 747

I am a beginner in developing Java desktop applications. I am trying to share the artifact with my colleague, but the .jar file does not launch on his PC.

I have IntelliJ, and JDK 14.0.1 installed in path C:\Program Files\Java\jdk-14.0.1. To generate artifact, I follow blog from JetBrains as below.

Create an artifact configuration for the JAR

  1. From the main menu, select File | Project Structure Ctrl+Shift+Alt+S and click Artifacts.

  2. Click the Add button, point to JAR, and select From modules with dependencies.

  3. To the right of the Main Class field, click the Browse button and select the main class in the dialog that opens (for example, HelloWorld (com.example.helloworld)).

    IntelliJ IDEA creates the artifact configuration and shows its settings in the right-hand part of the Project Structure dialog.

  4. Apply the changes and close the dialog.

Build the JAR artifact

  1. From the main menu, select Build | Build Artifacts.

  2. Point to the created .jar (HelloWorld:jar) and select Build.

    If you now look at the out/artifacts folder, you'll find your .jar file there.

I could able to execute the generated artifact on my PC. When the .jar is shared to my colleagues, it works fine on the PCs which have JDK installed in the same location as mine. But, on the PCs which doesn't have JDK, it gives below error messages when launched

enter image description here

and on clicking "OK", it says

enter image description here

I figured out the solution would be to install JDK on the systems which fails to execute. But, I suspect it is not a genuine solution. I would like to know the professional method of delivering the artifacts and what do I miss here?

1 Answers

If you don't want to install an "JDK", then you can convert it into .exe ; you will need a "JRE" minimum. You can convert it to an EXE, you will have to include libraries which have all the same information that a JRE has.

This link will help you in converting into .exe

Related