Where is the Java "jar" function - java

I'm looking to make a jar file out some Java code using jar [options] [name] [files] from the command line but it's not recognized.
According to Oracle Jar is part of the JDK. I have both 7 and 8 installed. How do I run the jar function?
I don't have a C:/Java that the Oracle documents show. I've tried running jar from within the JDK directories and with admin rights.
I'm not putting params in yet, want to check I can at least find the jar function first.
Running jar from JDK directory(1.8) http://puu.sh/eoer7/4fcd0ce63c.png
Running jar from System32 http://puu.sh/eoe3X/076d79b4e4.png

You have displayed two installations of the Java Runtime Environment (or JRE). You need to install a Java Developer Kit (or JDK), to get jar. Set your JAVA_HOME to the installation directory of the JDK, and add it to your PATH.
set "PATH=%PATH%;%JAVA_HOME%\bin"
Also, Using JAR Files: The Basics says (in part) JAR files are packaged with the ZIP file format, and you can use tools that can read and write ZIP files to work with them.

Related

some Jar files open with double click, others do not

Have 4 different Java projects, completely independent, and all build a Jar. All created in IntelliJ (2022.2.2 Ultimate) on MacOS (Monterey 12.6), built to target Java 8.
2 of the Jars open as expected by a double click, and 2 do not (error message to check for problems in log files via Console but could never find any).
The Jars all created within IntelliJ as an artifact of the project, and AFAIK the same process and options.
One of the Jars will also not open on the command line with either:
java -jar MyJarFile.jar (the Jar does contain the correct manifest)
java -cp MyJarFile.jar package.mainclass
but if you do:
unzip MyJarFile.jar
to unzip the jar into the current directory then:
java package.mainclass
starts the application as expected.
No change to the external environment (JAVA_HOME, etc) between any of the projects.
Something has to be different .... but what?
Any suggestions appreciated.

Extra dll files packaged by JavaFX installer between jdk 8u144 and 8u172

I am building an installer for a JavaFX 1.8 Windows application.
This application contains a JNI.
When I run the Ant script with the jdk 1.8.0_172, files named api-ms-win-core-*.dll and ucrtbase.dll are copied to the runtime\bin install directory. Those files are not present when I run the exact same script with jdk 1.8.0_144.
I have tested my program without those files and it works fine. What could be a path to investigate to understand how to get rid of those files?
Also, msvcp120.dll is updated to msvcp140.dll and vcruntime140.dll file appears (and is needed).
Thanks!

How to add jdk in a.jar file and run it

I have made a runnable .jar file. I want to run it on a PC which does not have jdk instilled, Can I add jdk in .jar file itself and run it ?
Suppose that your have installed your Java in the following path:
1 - copy this jre folder
C:\Program Files\Java\jdk1.7.0_25\jre
now all you need is to create a .bat text file with the following content:
#echo off
jre\bin\java -jar your_filename.jar
2 - name it as run.bat
that's all you need.
To wrap up things, the directory structure should be:
|---jre
|---bin
|---... // other files and folders
|---run.bat
|---your_filename.jar
click or create shortcut from run.bat and that's it.
If you are more interested in having a stand-alone executable file, then take a look at Launch4j (google it :) )
You don't need the JDK for it to run, just the JRE (Java Runtime Environment). You can download the JRE from here.
This is, unfortunately for you, something that will be needed to execute your code.

Running a Jar File in a environment without Java [duplicate]

This question already has answers here:
Running java without installing jre?
(8 answers)
Closed 4 years ago.
I made an executable jar file but I want to distribute it to users who may not have Java installed on there computers (Mac or PC). Is there anything I could do anything on my part as the programmer to make sure people without Java can run?
Other than 1) asking them to install Java, or 2) writing your own JVM, the answer is generally no. You have to have a JVM/JRE for your jar file, unless you have a development environment that can create a native executable from your code. But, then it won't be a standard jar file - it will be a native binary (if this development environment just bundles a JVM of some sort into package containing your jar file, with a small executable stub - this would still be putting JVM on their machine - it would just be a bit hidden from a user). So unless you can generate a native binary (not a jar file) from your source, no.
Same with writing something in .NET and attempting to execute it in an environment that does not understand what .NET is, writing something that requires a Python interpreter and trying to run it in and environment without Python, etc.
Running java without installing jre?
Create a folder(lets say PROGRAM) which include folders bin and lib, of your installed JRE.
In my computer I can find them at this path:
C:\Program Files\Java\jre1.8.0_25
Then with Launch4J create a JAR or Exe file of your program inside that containing folder(PROGRAM). Also when you create this file you need to manually select root to these bin and lib folders.
Then user dont need to have JRE installed, hovewer he needs to have folder with program and also bin and lib files in it.
If my english is not enough and these type of solution is what you looking for then heres another source...
How to bundle a JRE with Launch4j?
No need for Launch4j or any other software. Convert your project to .jar file in eclipse then after that put your installed JRE folder in the same folder where your .jar file exists.
Uninstall JAVA from your system then go to JRE folder in that bin folder then open command prompt.
Type:
java -jar ..\..\fileName.jar
i.e java -jar ..slash..slashfileName.jar
Make sure that the JRE installed file and your .jar file is in the same folder.

Installing Oracle JDK 6u38 on Fedora 17 in user home directory

In the older version of Java 6, Oracle provides the tar.gz distribution for their JDK, which can be extracted and run in user home directory without installing to system folder. However, the latest versions of Java are no longer distributed as tar.gz format for downloading anymore. Does anyone know how to install the bin distribution in user folder without root privilege?
I have tried to extract the bin files but it's not usable since most of the jar files are encrypted (or packaged) in some weird format (.pack), e.g. rt.pack instead of rt.jar. I have also tried to use --prefix in the rpm command line but it requires root permission. They seems to make it impossible to install java in user home directory.
Here it says:
The Java Development Kit files are installed in a directory called
jdk.6.0_ in the current directory.
And it looks quite simple, it just says to give execution permissions and execute a bin file.

Categories

Resources