I want my application to be usable on all computers, but it only works on mine.
Apparently this has something to do with it checking for versions of Java relative to the computer(???).
I'm either a fucking noob at Java, and has no life to not be using any good tools (a.k.a. primitive, ancient, and lesser-skilled), or there aren't that many tools for it (either way, I should understand why it's not working, if I wanna work in Java).
What I want to do is convert my .jae
which works on only my computer to a .jar
(yes, another .jar
, so that it's still platform-independent) that will work on ALL computers that have a JRE (native or manually installed).
Of course I'm too naive to understand any of this (since I'm so homosapien-like, I use CMDPrompt to compile and view errors (that VSCode didn't warn me of)), so, do any of you know of any tools I could use to accomplish my overall goal?
Thanks in advance! It means a lot to me.
Cheers!
Cheers!
Top comments (12)
✌🏿 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)maven MainProgram.java --uber-jar
ormaven *.java --uber-jar
(wildcard *).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!
.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).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, writecompiler.bat
, and compile my Java in to a Jar.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.
That's not so simple actually
Big applications like Android Studio or IntelliJ just includes their own copy of the JRE inside the app.
I googled a bit for you and found this docs.oracle.com/javafx/2/deploymen...
and also this
fvarrui / JavaPackager
📦 Gradle/Maven plugin to package Java applications as native Windows, Mac OS X, or GNU/Linux executables and create installers for them.
JavaPackager
JavaPackager is a hybrid plugin for Maven and Gradle which provides an easy way to package Java applications in native Windows, Mac OS X or GNU/Linux executables, and generate installers for them.
History
It was born while teaching to my students how to build and distribute their Java apps, and after seeing that a chain of several plugins was needed to achieve this task, I decided to develop a plugin💍 to govern them all.
How to use this plugin
Package your app with Maven
Add the following
plugin
tag to yourpom.xml
:I know how to do the second to last one, but how do I do the second one?
The solution is platform-specific. I believe you can find on SO.
But in essence, bundle JRE with the app.
How do I "bundle a JRE with it"? Also, what does "SO" in this case (StackOverflow)?
My process was to use Gradle to create shadow JAR. Maven also has a different plugin to create a fat JAR, I believe.
About bundling a JAR file, would you rather want users to install JRE? If not, which OS do you want to try first (which one are you running)?
In regards to the second to last question, it'd be fine, as long as the user can run the Jar, but I'm not familiar with any tools, so I want to know if there are any simple tools (for dumbasses like me). :p
Though, if it helps find anything, I'm using Windows 10.
If you use no build tools, just pure
javac
andjava -jar
, it should already be fat JAR by default, I believe.Well, it doesn't work on other computers, so, are there any settings I need to apply?