How to run Java project on local without any program?

Viewed 43

I have a spring boot project. How can I make the java spring boot project run on my local machine without using any application (Intellij IDEA, Eclipse, Heroku, Docker etc.)? I can do this using jar file on command line, but I want to use a different method. How can I do that on windows ?

3 Answers

Make sur that the JRE is installed on your machine (which is the case if you'r running .jar files from cmd) then open the jar file as any windows program, if you want to generate an executable .exe from your file then use launch4j.

GraalVM

Another more modern and efficient approach than launch4j would be to use GraalVM.

  • Install GraalVM
  • Install some C developer environment like Visual Studio
  • Run: gu install native-image

After compiling your Java code with javac compile as a native image

  • javac YourClass.java
  • native-image YourClass

Now you have an efficient executable that can run on its own anywhere.

At least this is how you do it manually.

You have a library for Spring, spring-native, to help you. Or you can develop your project using Quarkus instead, which can build a native image out of the box

Related