2

I'd like to create a detached/offline Java setup on Windows to roll out to other systems and VMs. I know that some applications bundle Java within them, but I was wondering if I can also create a Java installation that I can port to another system. i.e. I don't want to install Java from the Oracle installer, or from chocolatey or other package managers. I want to get a vanilla Java setup folder from one system, and then port to another system or VM, and ideally into a different folder from the default (C:\MyApps\Java).

The main obvious considerations are PATH and registry. Certainly, I would add the folder containing java.exe etc to the PATH. Would that be sufficient? Would a .jar file then use those binaries, or would I further need to add registry information as well as the PATH?

How would we create a completely portable version of Java in this way?

4
  • 1
    As you can see on Oracle OTN site you have archive with java files: oracle.com/java/technologies/downloads/#jdk19-windows (x64 Compressed Archive) Dec 4, 2022 at 10:10
  • 1
  • Thanks, that's a good start, but there is literally no explanation of how to make it usable to .jar files etc. I looked at the below link and it only talks about the .exe install. Do we just put java.exe / javaw.exe on the PATH and that's that? Java very often feels obscurantist I've noticed. Do you know how I use the .zip archive such that java apps can see/manipulate it? docs.oracle.com/en/java/javase/19/install/…
    – YorSubs
    Dec 4, 2022 at 13:28
  • I don't even particularly need the JDK (I think). I just want Java support on the system (so that would be the JRE I think). I only develop in PowerShell, Python, Bash, C#, so probably the JDK might be too much.
    – YorSubs
    Dec 4, 2022 at 13:31

1 Answer 1

2

How would we create a completely portable version of Java in this way?

You can do this with a cmd script:

  1. Copy the complete Java installation to the new system.

  2. Set JAVA_HOME to point to the root directory of your Java installation, for example:

     setx JAVA_HOME "C:\Program Files (x86)\Java\jre1.8.0_231"
    
  3. Add the Java bin directory to your path, for example:

     setx PATH "C:\Program Files (x86)\Java\jre1.8.0_231\bin";%PATH%
    

See Installing the JDK Software and Setting JAVA_HOME and PATH and CLASSPATH for more information.

1
  • Thanks David. If it all comes down to just JAVA_HOME and updating the the PATH, then that's great to know (I was hoping it was something as simple as this). I note the difference in paths; JAVA_HOME to the root of the jre and PATH to the bin folder. I'll convert this to PowerShell, and it should be perfect for my needs. Thanks for the tip.
    – YorSubs
    Dec 4, 2022 at 14:18

You must log in to answer this question.

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