Run a jar file without JDK installed - java

is there any way to run a jar file without JDK installed ?
for example convert jar file to exe or put the jdk or jre into the jar file or something like this...

JRE is a must. JDK is not a necessity.

Related

Installer File in Maven Plugin that puts exe and jdk to C:\\Program Files

I need to execute a Java exe file. But this exe needs jdk. I want to create an installer that locates this exe and jdk to under C:\Program Files and creates shortcut for this exe.
installer:
|
---jdk-11
---exe
Note 1: I want to use a spesific version of JDK and users should not install a JRE in their own computer. Exe shoud use the one that located by installer.
Note 2: The tools that I can use are very districted since I want to achieve this in pom.xml by using Maven Plugins
I tried javapackager for creating msi but javapackager plugin expects a wix tool which is not avaiable in maven plugins.

Open jar file using JRE on Mac

I have a jar file that is meant to be ran through the command line.
I am not planning to do any java development on the machines where the application will run and my thought process is that therefore I should only need the JRE and not the JDK. In addition, the JDK is like 4x as big as the JRE and I would like to not have to download it.
When installing the JRE on a Mac, it does not set the path for the java command and if I try to run it, osx prompts me to install the JDK.
I wonder if anyone could provide some insight as to how to use the java command in a mac without having the download the bigger sized JDK?
Thanks a lot.
Have you tried running this in terminal?
java -jar MyJarName.jar
However, you can also try and make a runnable application of the jar file. Take a look at Packaging a Java App for Distribution on a Mac
EDIT:
You can also try running your starter class from the terminal. cd to the bin folder of your project, then java packageName.className. For example, java my.package.Starter.

installing Apache Ant 1.8.4 on centos

I want to install apache ant1.8.4 on my centos machine. I've read in the apache website but i didn't really understand how should i do tha. I didn't find the package on their website.
Is there any option to use the yum install command?
There may be a way of installing Ant as a package. On the Apache Ant website, you do it manually. The tarball or zip provided has the entire Ant package installed. It's not that difficult:
Unzip or untar it to a special directory like /opt. I install all third party stuff in /opt on my system. Everything in the zip or tarball will be under the apache-ant-1.8.4 directory, so Ant will be under /opt/apache-ant-1.8.4.
In your .profile, set $ANT_HOME to where Ant was installed (/opt/apache-ant-1.8.4 in the above example. Then, add $ANT_HOME/bin to your $PATH.
Or, my preference, symbolically link all programs under /opt/apache-ant-1.8.4/bin to the /usr/local/bin directory and put that directory in the front of your PATH. This allows you to put all specially installed executables in one directory that can be placed in your $PATH.
That's about it. If you have the Ant executable (It's a shell script on Unix/Linux/Mac, and a batch script called ant.bat on Windows) in your PATH, it should work.
You mentioned you didn't have the Java Development Kit (JDK) installed. This must be installed first since Ant is a Java program. There must be a CENTOS package for Java. If not, you can try http://java.com/en/download/manual.jsp to download Java on your system.
Assuming you already have jdk installed, you could do the following:
cd $HOME
wget http://archive.apache.org/dist/ant/binaries/apache-ant-1.9.2-bin.tar.gz
tar xvfvz apache-ant-1.9.2-bin.tar.gz
In .bash_profile, add the following line
ANT_HOME=$HOME/apache-ant-1.9.2
PATH=$PATH:$ANT_HOME/bin
. ./.bashrc_profile
ant -version ##you should see version of ant.
(updated to 1.9.2 for wget)

unable to find javac compiler from an executable jar

I am working on a simple java editor that uses ant to call JDK.
On eclipse everything work fine, I am able to build build.xml. The problems is when I export my Editor to an executable jar, and I try to build the build.xml of a project, I get the famous problems:
Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:\Program Files (x86)\Java\jre7"
Important:
If i run my jar Editor from cmd it's work fine ,but if i double click the Editor jar it doesn't work , i get the famous problem (unable to find javac compiler...).
Notice:
JAVA_HOME points to the JDK.
I am using ant.jar and ant-launcher.jar.
Eclipse points to my JDK installation.
tools.jar is added to JDK/lib folder
the solution is to set fork attribute to yes on javac target .
Perhaps JAVA_HOME does not point to the JDK.
JAVA_HOME is currently set to C:\Program Files (x86)\Java\ jre7
The message is fairly informative and to the point, is it not?
Your JAVA_HOME looks like it is pointing to a JRE installation, not a JDK installation. (The error message says it is "C:\Program Files (x86)\Java\jre7"!)
A JRE does not include any of the Java development tools ... such as the javac Java compiler that Ant is trying to load / use.
If you really have a JDK installation on your machine, then all you need to do is to change the JAVA_HOME environment variable so that it refers to it ... instead of the JRE. Otherwise, you also need to download and install the relevant JRE.

JAR file does not load class files from ext

I installed JDK 1.6 on my Linux system, the $JAVA _HOME directory is /usr/java/jdk1.6.0_07.
I built the path on Eclipse to $JAVA_HOME. It runs smoothly through Eclipse and loads all third party JAR files from /usr/java/jdk1.6.0_07/jre/lib/ext/, but when I export the JAR file and run it, it throws ClassNotFoundExecption.
Why?
Did you install Java properly? Here are some instruction for installing Java 7 or Java 6
Are you sure that the version of Java you are using is correct one since there can be several versions of java on linux? Try java -version on terminal where you run it to check.
Do you use any third party library? If so, did you specify the class path when you run the jar file or bundle them inside your jar file?
What does java -version return? Are you using the same JRE for execution?

Categories