Java Executable Application [duplicate] - java

This question already has answers here:
How to make an executable JAR file?
(5 answers)
Closed 5 years ago.
I am an amateur Java programmer, and I have just started learning how Java applets work. However, I wanted to make an applet for my Chrome browser, but it no longer works because Chrome doesn't support NPAPI plugins (like Java and Unity 3D). I want to make a standalone Java executable similar to Minecraft. The idea is that once I double-click on the .jar file, it opens the application and runs the program.
The program displays text and images based on input from a text box.
How do I make the .jar automatically open on a double click?

To make a JAR which can be launched by double clicking, you have to make it an executable JAR. There must be a file META-INF/MANIFEST.MF inside the JAR with key-value pairs that point to the main class (the class with the main method) to run.
See Lesson: Packaging Programs in JAR Files in Oracle's Java Tutorials to learn exactly how to create an executable JAR.

No.
After the release of Chrome version 45, you’ll need to use an alternate web browser to load content that requires a NPAPI plugin.
But you can create application using Java Network Programming will help to create the application.

Related

Intellij JavaFX vs Java Project for .exe file [duplicate]

This question already has answers here:
How can I convert my Java program to an .exe file?
(16 answers)
Closed 3 years ago.
I have already a Java Project in Intellij.
I want to make a .exe Java file, but I did not find any solution yet for Java Projects. On the other hand, I have found many youtube videos in which they use a JavaFX Project to create an artifact which they will use to create a .exe file.
One of them is the following youtube video:
IntelliJ export JavaFX application to exe on Windows
My end goal is, that a user just double clicks on the file and a GUI opens. After entering some information the rest of the code should run. The file should be able to run to different windows systems, so this should not only work when installing special packages.
Did I chose the wrong type of project? To that I just read, that JavaFX will be discontinued.
I am confused in so many levels...
You should first make an executable .jar file and then use an .exe wrapper on the jar. I've used
Launch4j in the past with great success. I haven't tried it on javafx yet, but there are many executable wrappers to choose from with a quick google search. If this is at all unclear, leave a comment, and I'll detail these steps more. Launch4j has an almost self explanatory interface, so I don't think you should have trouble as long as you're sure your .jar launches.
What you're looking for is an executable jar file I think. I know that eclipse you can generate one so I'd assume you can do the same in intellij. How to

How to make an .exe and an .app from a JavaFX 11 application using Netbeans

I have a javaFx application developed with:
OpenJDK 11
NetbeansIDE 10
JavaFX 11
Following the javaFX 11 instructions (here) I have created a self contained app.
Unfortunately, to start the app a long command is required. Something like this:
dist/jlink/HelloFX/bin/java -m hellofx/org.openjfx.MainApp
This is not the best option for the end users.
My question is:
How can I create an .exe (Windows) and .app (macOS), easy to distribute and start?
How can I add an icon for the app (right now the app appears with the classic java cup icon)?
I was not able to find any updated directions for that.
Thank you.
Compile the executable JAR file, and then use a tool to convert it to EXE.
There are few ways of doing that:
Launch4j is one of them
Another option can be Jar2Exe

How can I make a program executable by double clicking? [duplicate]

This question already has answers here:
How to make an executable JAR file?
(5 answers)
Closed 8 years ago.
I wrote a JAVA program for my wife to compare coupons stacked with sales on different item sizes to save her time on her shopping-trip-planning. Now I need to put it on her computer in such a way that she can double-click something, and have the program run. I'm not finding anything good on the interwebs (like a decent step by step).
It is a simple program, one class with a nested class, and various imports of swing, awt, and text.
Since it's my wife's computer, I can make sure that she is running the appropriate JRE. Thanks in advance for any help.
You can use Launch4j application. That convert executable jar file to windows native executable application.
You can also embed JRE with it so if JRE is not installed on machine the application will run.
you can also add some other mechanism to it also like loading image, icon, etc.
I assume you are using Eclipse. In this website they given it very clearly for eclipse.
Create Executable files in eclipse
Export it to (or create a) executable Jar.
Most IDE's will do this (I think you have to dig around Eclipse a little) or take a look at Packaging Programs in JAR Files and Setting an Application's Entry Point if you want to do it by hand
Most GUI OS's will run the Jar via a double click.
You could also investigate generating a native executable wrapper, which will make the program "look" more familiar to the user, including launch4j or exe4j or Packaging a Java App for Distribution on a Mac depending on your target platform
Use NetBeans and simply 'Build' the jar file. This will produce an executable file within the 'dist' folder of your project.
Eclipse is the same however slightly more hidden.

Wrapping JRE with my JAR in one EXE file [duplicate]

This question already has answers here:
Bundling the JRE with a Java application
(2 answers)
Closed 8 years ago.
I have read many threads in stackoverflow but I didn't get the answer.
I used JSmooth and Launch4j but what I want exactly is to get a final .exe file from my JAR application and a JRE so that my windows client won't need to install any JRE (in another way: to get a portable application with its own JVM)
I found that is not possible but why? Does that need the compilation fo the jre with my application source?
I hope my question is clear, any help will be appreciated.
Zip the JRE folder and include it as a resource in your .exe file.
At run time, you'll need to extract that resource to the disk, unzip it and then invoke it using ShellExecute to run your .jar file. The size of your executable will probably be quite huge.
This is your only viable solution.. Otherwise, if it is for windows only, why not just write the whole application in C++? Is there a reason why you need your JRE with the application? Why not let the user install their own JVM?

Create executable package for a netbeans project [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Export JAR with Netbeans
I have created a NetBeans Project and now I want to create a package from the project. As this is my first project in NetBeans. Can any one help me to create a package from my project for distribution?
Expanding on the question for the .exe:
I have good experience using Winrun4J to generate an exe launcher for my Java applications. It's quite forward to setup and generate and it supports 32 and 64 bit Windows.
You can even put all needed jars into the exe.
http://winrun4j.sourceforge.net/
But (as you seem to be new to Java): the exe is only a wrapper. It still requires a Java Runtime to be installed on the system where you start the exe!
If you have several project in development environment, make sure you have set the project you want to distribute as a main project. It can be done via mouse right click menu on project name in the left pane.
Click on menu: "Run -> Clean and build main project"
Inspect your project folder, find folder dist in your project folder. There is *.jar file. It is packaged compiled project file.
If you want to code desktop apps. that will run on Windows, OS X & *nix, write them in Java & deploy them from a link using Java Web Start.
JWS provides many appealing features including, but not limited to, splash screens, desktop integration, file associations, automatic update (including lazy downloads and programmatic control of updates), partitioning of natives & other resource downloads by platform, architecture or Java version, configuration of run-time environment (minimum J2SE version, run-time options, RAM etc.), easy management of common resources using extensions..
I high-lit the part that is relevant to your next comment.
can I give my own icon image to the executable file?
Why should the user ever see a .jar (or a .exe for that matter)? JWS offers desptop integration, which might consist of a desktop shortcut and/or menu item on supported OS'. Either of those can have an image (within limitations) as supplied by you.
The deployJava.js script checks the user has the required minimum version (helps them to install it, if not), before running an applet or providing a link to a JWS app.

Categories