30

My question may seem odd but this is indeed what I need to do. For the first in the last (maybe) 10 years I have to run a JAR file in my computer. But I don't want to install 'the Java' (and all those things it adds into your system). How can I run that JAR file?

7
  • 1
    1. Too broad. Differs for each application. 2. That's asking for a recommendation, which is off-topic.
    – gparyani
    Apr 23, 2014 at 15:07
  • You can manually uncheck the box every time you install or update. Alternatively, you can disable it using the registry.
    – gparyani
    Apr 23, 2014 at 15:10
  • 3
    We don't solve questions by putting "solved" in the title. You should wait for @nixda to post his answer.
    – slhck
    Apr 23, 2014 at 16:08
  • 2
    Even if your question was actually an XY problem: the above is not a duplicate of the one you voted for. What are you trying to achieve with your edits of the title and that close vote? Given your reputation on SO I guess you know, but please remember that all Stack Exchange sites try to be a useful resource for future visitors.
    – Arjan
    Apr 23, 2014 at 21:20
  • 1
    "install" java is nothing more than putting a java executable and some other basic jars somewhere on your filesystem, you might end up using just another JVM environment to load your own JARs.
    – Sajuuk
    May 6, 2019 at 3:15

4 Answers 4

25

You have two options


  1. Use jPortable together with jPortable Launcher

    jPortable Launcher allows you to easily run Java JARs from your PortableApps.com-enabled device with the jPortable portable Java Runtime Environment installed.

    To use this, visit PortableApps.com and search for jPortable . A list of result should come up and then select the runtime environment and the launcher (links above). Then download both of them, and install per directions. A folder will be created where the downloaded files were run from. Inside one of them will be "JavaPortableLauncher.exe". If you launch it, you should be able to locate and open a jar file with the application.

    The Launcher

(or)

  1. Download and extract the Windows x86 tar.gz version and start your .JAR file from commmand line: start C:\Java\bin\javaw.exe -jar C:\myfolder\myprogram.jar
5
  • 2
    2 is not ok because it implies to install (now or in the past) Java on the 'another PC'. But 1 works.
    – IceCold
    Apr 24, 2014 at 9:22
  • 2
    If you are concerned or have no access to a second machine, you could always install Java in a VM, backup the Java folder and uninstall Java again. I'm using the secondf approach for almost every Java program I'd like to run
    – nixda
    Apr 24, 2014 at 10:00
  • Just wanted to add the comment that option two works now (edit from 2016)/Oracle offers directly the tar.gz file. I almost dismissed that second option after reading the comments from 2014.
    – Eleasar
    May 16, 2017 at 10:30
  • I have the Java runtime (jPortable) installed on my device/PortableApps/CommonFiles/Java. Where should I install the JPortable launcher? Same folder?
    – franz1
    Jan 18, 2020 at 14:13
  • could you please help here superuser.com/q/1518268/675927 ? thanks Sep 12, 2020 at 20:25
7

I remember that severel years ago you could download Java, unzip it, put it somewhere in a folder, and by pointing to the java executable in that folder you could run java. I don't know how it works today with the current versions, but I wouldn't be surprised if it still could work like that. Don't have Windows here, so can't test it, but you can download a zip (or tar.gz) file, unzip that and than work from there. If you can't unzip gz files, download and install 7-zip.

This won't install it like you normally do, so no update alerts etc, no browser integration, no system variables, but you need something to run that code, and this is the least I think.

http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html

Download one of the tar.gz versions.

1
  • 1
    +1 Didn't know they offer a tar.gz packet
    – nixda
    Feb 2, 2015 at 18:42
1

This just worked for me:

  1. download the Java installer for whatever version you want;
  2. open it with 7-zip;
  3. locate and extract the tools.zip file (it can be in different directories, depending on Java version, build, or if it is a JDK or JRE);
  4. expand tools.zip in some ;
  5. go into and run for /r %x in (*.pack) do .\bin\unpack200 -r "%x" "%~dx%~px%~nx.jar;
  6. try running bin/java -version.

If it works, thats it, you have got yourself a portable JAVA_HOME.

2
  • which "Java Installer" are you talking about?
    – Sajuuk
    May 6, 2019 at 12:55
  • @sajuuk, I meant the .exe you download from Oracle.
    – lpacheco
    Jun 5, 2019 at 10:23
0

The best way is that convert your .jar file into .exe . follow this : JAR2EXE

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .