DEV Community

loading...

Discussion on: How can I make my Jar file executable on all computers?

Collapse
jffrydsr profile image
Jeffrey Desir

✌🏿 Yo Calin, it's been years since I've considered myself a Java programmer, but I can help if you're just trying to create an uberjar... consider using a build tool like Maven. Assuming you're using Maven (Apache Project Manager)

  1. maven MainProgram.java --uber-jar or maven *.java --uber-jar (wildcard *).

  2. java MainProgram.jar


Why is a build tool recommended?
Why not just javac? Depends on what kind of executable you want, dependency complexity, etc.
Here's a nice diagram I'm commiting to memory by a kind Mr. Falkner
.

In short, if you want to guarantee your java executable has ALL it needs to run platform-agnostic, compile it's dependencies, runtime, and project code all together with zie uber-jar!.

Collapse
baenencalin profile image
Calin Baenen Author

I'm not sure I fully understand what's going on. As I said, I'm primitive. It's like your showing bacteria fire, and getting it to understand.
I don't mean to burden to ask, but can you simplify it, and maybe link some explanations/documentation?

Thanks for your help so far.
Cheers.

Collapse
jffrydsr profile image
Jeffrey Desir

P.S.
Visual Studio has a Java extension.
I'm curious to your build process; I've haven't generated anything but .class & .jar file types with a java build. I know JAE is Java Application Environment; I wonder is that some minified JRE for your artifacts or is my Java really that weak? (no regrets, Clojure liberated me from OOP).

Collapse
baenencalin profile image
Calin Baenen Author

You are curious? I'd love to explain. Though, I don't fully understand the question. or what you mean by "build process" specifically, since I (kind of) explained in my post.
All I do is write some .java, write a manifest, write compiler.bat, and compile my Java in to a Jar.