this is a kind of weird non programming (but java related) question.
I created a java program (game) using just normal java, and no libraries.
In ordor to double click/open it, you need to have java SDK/JDK (I don't know which) installed.
I tested this multiple times, and in order for my PC and Mac to launch it, you need to install it.
is there anyway to get around this? I know Minecraft doesn't force you to download the JDK.
Here's the link to source code of my game if your interested (no, it is not a virus): http://www.filedropper.com/daplatform
Thanks, Jake
Here's the link to the download of the JDK (Its next to the giant Netbeans download): http://www.oracle.com/technetwork/java/javase/downloads/index.html
What you can do is you can wrap both your program and the JRE required to run it into a single executable for the target platform.
For example your windows installer would include both a windows JRE and your program itself.
Launch4j http://launch4j.sourceforge.net/ lets you wrap a Java program into a windows executable and gives you options about how to handle the JRE, including bundling it.
Related
OK, I’m still a little overwhelmed by all the choices for deploying an application. My case is really simple. I have a Java program that’s now working in NetBeans on Win7. I want to run it on another Windows desktop that doesn’t have NetBeans.
The method presented here: https://netbeans.org/kb/docs/java/native_pkg.html produces a single .exe file that installs the application on the Win desktop. But, that file is huge because it includes all required portions of the JRE.
The method presented here https://netbeans.org/kb/articles/javase-deploy.html uses the JRE already installed on the Win desktop so the distribution is very small. But, it requires you to distribute both a .jar file and a lib folder.
So, finally, the question. Is there a method that uses the already installed JRE and only requires the distribution of one (small) file?
Thanks.
Since that second option has everything you need to run the app (provided that a JRE is available), you can use that with a third party install packager like izpack
If I am understanding correctly:
It will allow me to send an embedded JRE along with my JAR so that my jar works whether or not the user has Java installed on their computers.
I have never worked with it before so I thought I might ask before going on a steep learning curve :)
Launch4j does not embed the JRE. It is a wrapper for your JAR file which checks for an appropriate JRE installed on the target PC, and if it is not installed it will offer the user to download it.
I made a simple text based game that runs on my computer, but my schools computers have an older version of java and can't run it. I tried compiling the .java file in from the computers command prompt but I can't access where the javac folder is to compile because the school computer blocks everything. The command prompt is even disabled by the administrator unless I open it with a batch file. I tried wrapping the jar with the JRE in Launch4j but the exe does nothing, it loads and that's it, nothing comes up (I think it's because the text game is supposed to run in the command prompt so there is no GUI to print any of the text)
How to get a Java program to run on a computer without modern JRE?
my schools computers have an older version of java and can't run it
Use the cross-compilation options of javac when compiling it at home.
You are running into a bit of a contradiction here; Please take notice on what exactly you are asking:
"How can I run a Java Program without Java?"
Do you get it? You are basically asking "How can I drive a car without the car?"
As for the actual problem, all hope is not lost. Here are some options:
If possible by any means, simply install the latest stable version of Java on the machine.
From a computer that has JRE/JDK installed (or through another form of access to the JavaCompiler, AKA JavaC), recompile the code to the older version of Java using the command-line parameters for source and target java versions (Note: I am unsure if the JRE/JDK for the older version must be installed in the machine or not).
For this case, you might want to take a look at this and/or this.
Choose another language to work with, and re-do your code into that language; You can't run Java code without Java, the same way you can't travel by train without the train to travel with.
I have a friend without java. I want to package my executable .jar file with java platform SE binary in an exe file so he can run it without downloading the entire java runtime. Could someone point out some kind of software that does that?
I have a friend without java.
And you call them a friend? ;)
Use deployJava.js to check the user has the minimum Java required to run the app.
Install & launch the app. using Java Web Start.
Give the user a link to the 'launch' web page.
This will work on Windows ..and OS X ..& *nix.
Try using Launch4J at http://launch4j.sourceforge.net/
Here's the highlights:
Launch4j wraps jars in Windows native executables and allows to run them like a regular Windows program. It's possible to wrap applications on Windows, Linux, Mac OS X and Solaris!
Also creates launchers for jars and class files without wrapping.
I have also had good experiences with Launch4j. Also check out JSmooth: (http://jsmooth.sourceforge.net/index.php) which claims to have an option to download and install a JVM if one is not available.
I make my executable jar in exe format, but I want to add JRE with this because if JRE is not present in their machine, they can use it with this included JRE.
But I do not want to install this JRE in their machine. This JRE is only used by this application only. It will just like game or other application. I use launch4j to make jar to exe but i did not find any option from where it can attach JRE and it has no option from where I can link my jar dynamically.
How do I achieve that?
If there is other free installer then mention it, and please give the procedure with example.
Since it has been established that your app. has a GUI, I will suggest Java Web Start as the answer.
But I do not want to install this JRE in their machine.
That is not a sensible requirement. The user might already have a usable JRE installed, if they don't they probably also don't want every Java based application to be installing its own 'private' JRE.
Oracle's deployJava.js can do the checking, and help guide the user through the steps of installing (which basically comes down to click 'OK' when prompted).
I make my executable jar in exe format,..
If you only intend to support Windows, what is the attraction of coding in Java? JWS supports any platform for which Java is available. That brings a lot more potential customers for the app.
I want to use free installer.
JWS is entirely free. Just like the JRE.
..please give the procedure with example.
Do you run an IDE? If not, do you otherwise have Ant installed? If that is a yes to either one, check out my small JNLP API examples. Each comes with complete source and a build file (an Ant build.xml).
Within a couple of keystrokes & a few moments, you can see the app. installed and launched on your desktop. For the end user, it is even simpler. Just click a link in a web page, and it all happens automatically (possibly with a security prompt - for the protection of the user).
I like JSmooth. You can give it a try here:
http://jsmooth.sourceforge.net/features.php
Flexible automatic Java VM detection
Detects the location of any Sun JVM installed. The wrappers use
several strategies to detect all the JVM available on a computer,
using windows registry, environment variables, windows path.
Detects
and uses Microsoft's JView (for 1.0 and 1.1 Java applications), if
available.
The JVM search sequence is fully customizable using the
GUI. You can force the executable to search in the path first, and in
the registry last, or in JAVA_HOME first. We have all the flavours!
Sometimes it's more convenient to bundle a JRE with your application.
JSmooth can deal with that too, you just need to define in which
folder the JRE is expected. It falls back nicely to a standard JVM
search if the JRE is not where it should be.
Specify which versions of
the JVM are compatible with your software. You can set a minimum
version, but also a maximum JVM version.
Documentation: http://jsmooth.sourceforge.net/docs/jsmooth-doc.html
Take a look at launch4j.
I had to use it, and it worked out very well.
You can set a minimum version of a needed JRE, bundle a JRE, or if a JRE is not found (and not bundled) the launcher may lead the user to a download location of an appropriate JRE.
There are various further features launch4j offers, and as opposed to another suggestion here, launch4j is activly developed
http://launch4j.sourceforge.net/