We have a Java EE application which requires some jar files, a JVM and Tomcat.
How do I create a build through which a user can install and run my application in a non Java Windows environment?
The user won't need to install a JVM or Tomcat separately, but my build will configure a JVM and Tomcat for my application.
The Java installer creates a couple of registry entries but these are not necessary for it to run. So what you can do:
Ask for permission to package Java along with your code (the Java VM is copyrighted work, so you can't simply do what you want)
Install Java once and then simply add the new files on the hard disk to your installer
Unpack Tomcat and add those files as well
Copy your app into the tomcat/webapp/ folder
Write a script that packages and configures everything
Related
I have developed a desktop Java application on Windows using Eclipse. It is just a console application. It uses several third party jar files and on Windows, several third party dll files are also required.
On the Windows machine, I can run the app from a command prompt as well, which I have copied from Eclipse. The command prompt references several of the third party jar files in the -classpath argument. In the development environment on Windows, all the dll files have been placed in the project home directory. The third party jar files have been included in the project Properties, "Java Build Path" setting on Eclipse.
Now, I want to move and run this app to a Linux computer for deployment. How should I do it? One way would be to use the same command line that is being used on the windows machine with modified -classpath arguments with the destination of third party jar files on the Linux machine. Is that the right approach? On the linux machine, I would also need the third party Linux native .so files. Should I just copy them to the project directory on the Linux machine? Should the project directory structure be same as the one I have on my Windows development machine?
Or should I just export (Eclipse Export) everything into a jar file and run the app using java -jar myapp command? Where should I place the third party jar files and native .so files in that case?
I have read a lot on this topic but still cant get any clarity on whats the best approach especially with third party .dll, .so and jar files involved.
Can all those steps be accomplished with Inno Setup or do I need additional software?
Create a standalone .exe installer for a Java application (either a main JAR plus libraries or a Uber JAR)
Bundle a JRE
Create a Desktop shortcut so users can start the application manually if necessary
Set up the application to run on startup
The answer could be either "yes" or "no, you would need the following additional software...".
Unless it's considered too broad a basic script would be appreciated too, but this is optional.
Instead of INNO setup, I use NSIS (https://sourceforge.net/projects/nsis/), it's open source software, and very powerful, you can use script.
Create a standanlone .exe installer for a Java application (either a main JAR plus libraries or a Uber JAR)
A: Yes, you need additional software like Launch4j(http://launch4j.sourceforge.net/) , or if you use Eclipse or IDEA there is built-in tools to create executable application
Bundle a JRE
A: Yes, use NSIS script you can bundle JRE installation
Create a Desktop shortcut so users can start the application manually if necessary
A: Yes, use NSIS script you can Create a Desktop shortcut
Set up the application to run on startup
A: Yes, NSIS script you can write windows registry. depends on where you put, Programs defined in Run, RunOnce or StartUp will be loaded in following order:
HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce
HKLM\Software\Microsoft\Windows\CurrentVersion\Run
HKCU\Software\Microsoft\Windows\CurrentVersion\Run
StartUp Folder
HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce
I want to create a executable jar file of a small game that i wrote in java and make it playable in any machine with simple double click like exe file. My question is do you need to install java runtime first in order for executable jar file to work or can it work on a machine without any java installed as well?
No it can't. However, clients do not require the JDK, the JRE would do.
You can make your jar declare its own main class and have users double click it normally like an exe file or create a bat file in Windows.
It requires a JRE instance to be installed on the host machine. This is because JAR files are actually executed via a command line like (in Windows):
java -jar ...
This means that somewhere on your system the java.exe executable should be reachable, either by including its folder in the PATH (Windows) or replacing java with its full path.
Also, most likely you will need to have all the runtime Java libraries to be hosted on the system, as the JAR file containing the application you want to run is not supposed to contain all the Java API libraries. They are also part of the JRE package.
My explanation is tied to Windows for the sake of examples, but it can be extended to any OS.
Do you need to install java runtime first in order for executable jar file to work?
Yes, of course. To run Java .jar files first you need to have installed at least the JRE (run time environment). The JDK (development kit) is a superset of the JRE and will also work for running .jar files.
Can it work on a machine without any java installed as well?
No, as mentioned above, at the bare minimum the JRE must be installed.
You have to have a Java runtime environment (JRE) available on the machine unless you use a tool that performs ahead-of-time compilation (AOT, which is contrast to the usual Just-In-Time). Such tools are available (such as Excelsior JET), but they have a number of downsides, including cost and the fact that a precompiled Java application is a regular executable and will only run on one operating system. I've seen some installers that will detect whether a JRE is installed and launch the Java installer for the user if not.
Yes ! of course, JRE is required and it is not compulsory for JDK to be installed. Since, the main class is defined in JRE for .jar files, it is necessary to have JRE on your machine. I tried with Windows OS.
Actually you can bundle JRE within your exe file with several java .exe wrappers.
Here are few of them JSmooth, Launch4j, Jar2Exe.
I have written an application in Java\GWT, It needs a database and Tomcat.
With what program can I create an msi File? that database, Tomcat and my application will be installed?
I know InstallShield and it is very expensive.
I want my application to be someone. He just wants to run a setup and then use it (all in one setup e.g. install App, Database and Tomcat incl. conf.)?
NSIS (Nullsoft Scriptable Install System) is a great open-source tool for creating windows installers - http://nsis.sourceforge.net/Main_Page As far as I know it does not support MSI but it's still a great tool if exe files are ok.
http://wixtoolset.org/ is also open source and creates MSI files but I haven't used it and don't know if it's any good.
We are working on packaging Java 7 application for Windows using install4j. The problem we are having is that on my Windows 7 computer I need to run the installed application as administrator for it to work properly. It fails at the point in which it needs to access the disk. If I run it as administrator, then it works fine.
Is there a way around this? I have used other application that were packaged with install4j and access disk and I did not need to run as administrator, so I suspect what I want is possible.
Thank you in advance.
What kind of application is it? Usually all applications are going to be installed in C:\Program Files folder. And probably install4j tries to install your application to the C:\Program Files folder.
Regular users (not admins) are not authorized to alter this directory neither create new folders there.
Is it necessary to install the application or it is enough to just wrap it in exe file to launch?
If installation is mandatory, i.e you need system folders, access to system dlls, then admin permissions are required and it is logical.
If you can omit installation and use a portable exe-file, then use an exe-wrapper for java applications. For instance - JSmooth