Running a java exe out of the SDK - java

I created a program using Java 8(JDK 8), but when I try to run it on a device that isn't mine (so no JDK), it makes me download a JRE.
1) why don't all programs when you download them make you do this? Is it just most programs aren't using Java?
2) how to I create an installation exe to install the JRE and the program. (As of now I'm just running my program as an exe).

Is it just most programs aren't using Java?
Yes, java is a popular programming language but most (desktop) applications are not written in java.
Some programs do also come with a JRE, meaning that it is installed with the program.
how to I create an installation exe to install the JRE and the program.
The exe could try to download the JRE from the API of e.g. OpenJDK, execute it and wait until it finishes, you could bring an installer with you, you could tell the user to install a JDK or you use an installer template that does one of the things for you.

Related

How to download latest java version 8 using powershell script [duplicate]

On a Windows server, I am looking for a robust way to download latest Java SE Runtimes from command-line .
My requirement is to check if java is installed on the system.
If java is not found, our MSI installer (created with WIX) need to connect oracle java download page and silently download java installer in the background and invoke the installer silently.
Download option can be in VB script/PowerShell/batch/Java
Installing java silently is easy with jre-8u121-windows-x64.exe /soption.
I could find couple of solutions to download jre on *nix with curl/wget
from this post
However, couldn't find any robust solution on Windows.
Please let me know is there a fool proof way to download JRE installer on Windows from command line.
I'd go with chocolatey, its simple, easy and handles all the pain for you (like keeping up with the new versions or when the link changes, etc)
cmd.exe /c "MD C:\Install-temp&bitsadmin /transfer Download /download /priority high https://javadl.oracle.com/webapps/download/AutoDL?BundleId=236886_42970487e3af4f5aa5bca3f542482c60 c:\Install-temp\Java.exe&start /wait c:\Install-temp\Java.exe /s & RD c:\Install-temp /S /Q"

Installing Java executables on Windows 10 machines by example

I imagine some Java gurus with experience delivering Java apps on Windows desktops will be able to ace this one. I've always been a Mac/Linux Java developer so this is uncharted territory for me :-/.
I have to write a Java 8 Swing application and install it on a Windows 10 (64-bit) machine. My gameplan is to package the app as an executable JAR and wrap it with Launch4J, so that it looks like a native Windows EXE (.exe file). However its a little bit more complication than that when it comes to the distribution:
There will be the JAR/EXE as mentioned above, lets call it myapp.exe (built from myapp.jar)
The app will output logs to a (local?) directory, myapp.log
The app will load a config file at runtime, myapp.properties
The distribution should also contain the User's Guide, MyApp User Guide.html
Let's assume a Java 8 JRE/JDK is already installed on the machine, so we don't need to worry about installing Java itself.
The installation process must be simple and include:
Removing the old version (and all of its other artifacts such as the log file, config/properties file, user guide, etc) off the machine completely
Installing the new version at either the Windows 10 default location, or allowing the user to specify a different location
Additionally, if at all possible, I'd like the installation process to include:
A requirements check for things like minimum memory and disk space, OS version info/compatibility (i.e. make sure its being installed on Windows 10, etc.)
Provide an easy-to-use wizard such as an MSI that the user can click though
Optionally install shortcuts to the user's Desktop
Given all this, I'm wondering what my options are in the modern Windows 10/Java/Launch4J landscape. Are there tools that will help me script together MSIs quickly, or do I have to write my own in, say, C#/.NET and have that be a separate binary/project? If MSIs aren't an option, what options exist that might hit all my bullets above?
I realize I could just distribute the whole thing as a ZIP, and have the installation process look something like:
Save the ZIP to some place on the user's machine, say, the Desktop
Move the previous app and its artifacts to the trash, manually
Unzip the new ZIP
However that feels janky and I'm looking for something more professional. Any solutions here?
JDK 8 is bundled with a tool called javapackager (formerly javafxpackager) which is part of JavaFX. However, you can use it package java swing application without using JavaFX. This tool can generate an installer file (exe or msi) which contains the application and the Java runtime as well.
Here is an example:
javapackager -deploy -native exe -Bruntime="C:\Program Files\Java\jdk1.8.0_66\jre" -Bicon=app_icon.ico -BsystemWide=true -BshortcutHint=true -outdir packages -outfile appFile -srcdir dist -srcfiles MyApp.jar;COPYING.txt -appclass somePackage.MainClass -BlicenseFile=COPYING.txt -name appName -title "The application name"
For more information, see adding icon to bundle using javapackager
There is also a new tool called jpackage which is based on javapackager. It is proposed to be released with the next JDK release, JDK 14. Note that javapackager was removed from JDK since version 11 as part of the removal of JavaFX.
See A Brief Example Using the Early Access jpackage Utility
Tools: Some deployment tools information:
Multi-Platform Installers
List of the major MSI installer tools
WiX quick start tips (the open source, free tool with a heavy learning curve)
"Hello WiX - step-by-step in Visual Studio"
"Hello World" - WiX style
Advanced Installer: As stated in a comment above you can use Advanced Installer to install Java applications on Windows and Mac (no Linux support).
Videos: Here are some videos from Advanced Installer (commercial tool) on Java installations:
Hello Java Installer: 1 minute video that shows the basics of installing a Java application
List of Java-related videos: https://www.youtube.com/user/AdvancedInstaller/search?query=java+jre
Tutorial (to read): Package your Java application for Windows and for Mac OS. Java landing page.
Digression: Not Java as such - do have a skim. Auto-updating applications using various deployment technologies: What is the best practice to auto upgrade MSI based application?
Links:
Make Installer of java Application
Installer for Java Web Application
How to create windows installer
How to create a MSI Windows installer for a Java program?
Old: How can I convert my Java program to an .exe file?

Installing Java for Mac?

I have a Macbook Pro running El Capitan (10.11.6). It doesn't come with Java and the advise I heard is to not install it because it's unsafe (and apparently Oracle bundles the installation with some ask bar tool or adware so I don't want that).
However, is there a way to code in Java without that? When I try to run Java programs from terminal (java foo.java), it tells me I need it. Is it just the browser plugin that's unsafe or should I keep it away from my computer entirely?
You can't, Java programs run in a virtual machine that you need to install (by installing the Java Runtime Environment).
You shouldn't run into any risks just by installing Java in and of itself, as long as you run programs that you know you can trust. If you really want to feel safe, disable the Java plugin from your browser (Actually, I checked and my broswer doesn't have any Java plugin installed, so you don't even need to do that). The toolbar is completely optional, just uncheck the option during installation.
If you want to write Java code you'll have to install the Java SDK too.

How to make installer on Linux, Mac, and Windows?

I have developed a program using Java SE on Windows 7.
I build this app and it runs well on Windows.
I tried to run on Linux, so it runs but after some steps of:
Removing OpenJDK app.
Install Java JDK from terminal
Run jar file from terminal.
I need to make an installer on Windows - Linux - Mac, which installs JDK package and make the program run by double clicking.
Try using JarSplice. It is a nifty tool for converting Jar files into runnables for different systems. There are lots of tutorials on the internet on how to use it, although it is very well labelled and I found it simple enough to use.

auto run the java application from pen drive without java installed

I developed a java application and converted it in to an exe file. When I plug in the thumb drive or pen drive, the application can launch in systems with java installed, but when I run it on a system where java non installed, it asks to install.
My question: Is there any technique or third party tool for launching the java application without installing the java on a system?
Its like plug the pendrive and launch java application.
A Quick search on SO gave this solution for packaging a Java App into an EXE and not needing to install the JRE.
running a java program as an exe in windows without JRE installed

Categories

Resources