I created an installer that works fine on OS X and Windows. On Ubuntu I get the message "The file '/media/administrator/UNTITLED/installer.jar' is not marked as executable" when trying to right click and launch with Java.
It works after I set the executable bit, but that's not the experience I expect from an installer.
The installer was built on OS X and I also tried to preset the executable bit via ant chmod, but I assume that This is lost or prevented on Ubuntu for security reasons?
Is there a way to reliably preset the executable bit?
If not, are there alternative tools for creating double-clickable Installers that work on Ubuntu without users having to manually set permissions?
Seems the answer is "It's not possible. You need to create a .deb package to get the desired behaviour".
Right click on the file and go properties, then select permissions and check "Allow executing file as program".
EDIT:
Or alternatively, set the jdk/jre as default program for .jar type. (this is one thing you can not control by your installer)
Related
We currently ship a java(jar) installer of our application. Taking into acount the changes to jdk11 we want our users to have the same easy install experience. So, what we are looking for, is to have just one file that can be run even if there is no java installed, it should just start our old java installer.
Probably, this means that we jave to bundle the jre and have a script that runs the jar, but the problem is how to run the batch file natively ? We need this to work on Windows and Mac. Most tools we are looking into require java to run the wrapped jar.
You have to build 2 different scripts/installers, one for each platform. Even looking at very popular software like Chrome, the platform choice is still there (even though you're usually directed to the correct choice based on the information your browser provides them with)
Depending on how much time you can put in this task, the quickest (and dirtiest) solution would be having an archive for each platform that contains the script .bat for Windows and .sh for OS X together with the jre (also different per platform), ask the user to unarchive and run the script which will run your jar with the packed jre. Otherwise, you'll need to create an MSI/exe for windows and a dmg (or other installer type) for MacOs.
I have done the dmg before with a bundled jre and can try to look for the details if you need them (I no longer have access to the code but can probably find the details). It was a free solution but it did require an OS X computer to create the dmg.
One option that I used before and works very well is install4j but the price is not small.
LE: Self contained packaging - although I haven't used this before, it seems like the best current option for your problem.
And an open source option - packr.
that Self Contained packaging doesn't really help, same for packr, same for launch4j. Because all those just generate a application image with a lot of files and directories.
Problem is before that, as an installer you want 1 big exe (or dmg for mac) that does it all, single click
We are already at the stage like SCP or Packr. Because that is easy or current installer.exe and jre\ sub dir and a batch/sh file besides it. Problem is how to get from that directory structure to a single exe that runs.
So what we should have is something that can zip that in a self extracting archive, when clicking on that it should auto extract to the temp dir of the OS, then run directly a command on it (like a batch file or directly in that extracted dir: .\jre\bin\javaw.exe -jar installler.jar)
But nobody seems to have made such a thing, the closest that we have is eclipse with Oomph:
[1] https://git.eclipse.org/c/oomph/org.eclipse.oomph.git/tree/plugins/org.eclipse.oomph.extractor/src/extractor.c
[2] https://git.eclipse.org/c/oomph/org.eclipse.oomph.git/tree/plugins/org.eclipse.oomph.extractor.lib/src/org/eclipse/oomph/extractor/lib/BINExtractor.java
problem is a bit that is doing the extracting through java and still wants a vm first.
I'm experimenting with Java for the first time.
I'm using Intellij IDEA and creating a simple app.
In the IDE it's working fine, then I create a JAR artifact and run it like this:
java -jar myappname.jar with no problem.
Now I would like to start the same JAR with double-clicking it from explorer but nothing happens, why?
Please note that if I double click another JAR (sikulixsetup-1.1.3.jar) it starts correctly and show the gui, so the problem is not type association in windows.
My test app does not have a gui but I know if it runs correctly because it's automating windows using Sikulixapi library, so I see if it's doing something or not.
thanks!
Ok, I solved my issue.
Usually the JAR runs without any problem by simply double clicking it in windows,
in my case it was not running becase the .jar files was associated to the 32bit version of javaw.exe while the code in the JAR was expecting the 64bit environment.
Changing the .jar type association in windows from 32bit to 64bit version of javaw.exe solved the issue
Its because jar is not executable binary but plain zip archive. OS cannot execute that. That is why you must use java executable and pass archive as argument to run your application.
If you want your app to be "clickable" you must use some wrapper solution like http://launch4j.sourceforge.net/
Change the default program to use while opening the file from one Java to the other (32 to 64 bit or vice-versa).
I'm trying to send a copy of a GUI game I made to my friends, but they are getting the error: No Java Runtime Environment Found.
I'm using Jar2Exe to turn the jar into an exe.
I found this solution online, but I don't know where to start.
"If you want your software can run on a pc without JRE "installed", you can select to copy a 'jre' along with your program and pack them into install file together."
How can I bundle a jre with it? I don't want this to be an install file, I just want it to run off an exe.
im a little confused here, i think all computers must have installed JRE, because java is used with so many aplications, for example if you could achieve to bubdle JRE inside your game ( jar file ), what happens if your JRE is for windows, and your friend want to play in MAC OS X, or GNU/LINUX?
if you made you game should work in each OS, obvioulsy the require JRE for their respective OS, but if you are getting an error then os not problem of JRE, but your game...
I made a little minesweeper game and I want to send it to a friend so he can test it out. The problem(probably) is that he isn't able to run it because he doesn't have Java for programmers(JDK) installed on his computer. How is it possible to export a program that will work on other computers without having to download any other files**(other than JRE)**?
EDIT: I did read about converting the JAR to EXE but I couldn't find anything that would do it.
EDIT2: Download here the JAR file(it's only supposed to open a blank window). I tested it on two computers with JDK installed and it worked, whilst on two others without JDK(one with the newest JRE) it couldn't start. This is the error:
.
There is no way to "not have to download any other files" - your friend must minimally have some Java Runtime Environment (or just "Java") installed in order to run Java programs.
If your friend has Java installed, you can package your application as a fat JAR so that he only needs your JAR to run your application (depending on the application - but I think yours should be fine).
There are tools available, google "java windows executable" and you will find e.g.
Convert Java to EXE
http://jsmooth.sourceforge.net/
Or already on SO
How can I create a Windows .exe (standalone executable) using Java/Eclipse?
Java Web Start is ideal for this, as it can enable the user to install required components on supported platforms. There's a simple example here.
Not possible, a JRE (Java Runtime Environment) is the least that must be present.
If that is you can just export your program as jar specifying the main class in its manifest. Your friend should if a JRE is installed be able to run the jar file directly.
You could send your friend the compiled binary of your game. In that scenario, your friend will only need to have the Java Runtime Environment installed in order to play your game.
Make executable JAR from it, your friend will still need JRE.
Is it possible to create a stand alone application in Java (using Swing) and package it into an exe file?
My Idea is, we should be able to double click it and run the application.
If you export a runnable .jar file you will be able to double click and run, but you'll still need the JVM in order to interpret the bytecode.
The best way to deploy a Swing based app. to a client's desktop is using Java Web Start.
JWS offers desktop integration - making a desktop shortcut and menu item, each using an icon if specified. The end use can double-click the desktop shortcut cut to launch the app. ( or single-click the menu item to do the same ;).
Best of all, JWS works for all platforms for which the J2SE is supplied. Windows, Ubuntu, Fedora, Solaris, Mac. OS..
For ensuring the user has the correct minimum JRE needed to run the app., use deployJava.js to write the link to the JNLP launch file.
If you export your project in a .jar file, you will be able to run it when you click on it.
I suppose that you know that you must have the virtual machine installed in the computer that runs the program.(The virtual machine is the thing that allows java to be operative system independent)
And also you must know that if you transform that .jar to an .exe file using some kind of gadget... Then java will not be java anymore, because will not be able to run it in non-windows operative systems.
Remember java slogan
'Write once run everywhere"
See this image here i will explain you how to create a .jar using the eclipse IDE:
1-Select your project in the package explorer
2-Select File>Export from the menu
3-Pick Runnable JAR file from the dialog and
4-Click next and follow the rest of the wizard
You can package your application to JAR file. Application in jar file runs on duoble click.
Here is tutorial. http://download.oracle.com/javase/tutorial/deployment/jar/
You can already do this with a normal .jar file if the user has configured the extension to be executed with the JRE. But you can always use something like Launch4J. Please Note this simply wraps the Jar in a EXE file. The file still needs your Dependencies (.jars) and the JRE enviroment.