Installing Java manually on Windows? [duplicate]

2020-02-07 18:01发布

I have seen many products bundeled with JDK, I wonder if there is a way where one can install JDK by simply unzipping contents to a directory, so there is no icon created in add/remove programs, no registry entries etc.

Also in this case: How can we configure Java plugin for browsers? And how can we configure settings as seen via Control Panel entry for Java?

8条回答
戒情不戒烟
2楼-- · 2020-02-07 18:03

If you just want to provide a JVM with your application is fine, but more than that I would not recommend.

查看更多
▲ chillily
3楼-- · 2020-02-07 18:13

You could use SysInternals RegMon and FileMon (now owned and dist by MS) to see exactly what is modified by the Java installer. I believe there will be a number of reg entries that you will want to create. Products like WISE installer, for example, also use this sort of approach under the hood to repackage product installations (e.g. as MSI).

Please be careful since there are also some dynamic decisions made by the installer which may affect what gets installed (e.g. on XP v.s. W2K3 server). I was bitten by this once regarding installed codepages. I do not recall the precise details, but the effect was that a codepage file was missing in my embedded JRE + JDK (legally redistributable portion only). This caused a very bizarre and seemingly nonsensical runtime error in my code. It goes without saying that the same applies to Server v.s. client JVM DLLs.

查看更多
够拽才男人
4楼-- · 2020-02-07 18:15

According to this, I created a batch script to build jdk archives automatically.

The essential parts of the link are:

  • Create working JDK directory ("C:\JDK" in this case)
  • Download latest version of JDK from oracle (for example "jdk-7u7-windows-i586.exe")
  • Download and install 7-zip (or download 7-zip portable version if you are not administrator)
  • With 7-zip extract all the files from "jdk-[6-7]u?-windows-i586.exe" in directory "C:\JDK"
  • In command shell (cmd.exe) do the following:
    1. change directory to directory C:\JDK.rsrc\JAVA_CAB10
    2. execute command: extrac32 111
  • Unpack C:\JDK.rsrc\JAVA_CAB10\tools.zip with 7-zip
  • In command shell (cmd.exe) do the following:
    1. change directory to C:\JDK.rsrc\JAVA_CAB10\tools\
    2. execute command: for /r %x in (*.pack) do .\bin\unpack200 -r "%x" "%~dx%~px%~nx.jar" (this will convert all pack files into jar)
  • Copy whole directory and all subdir of c:\JDK.rsrc\JAVA_CAB10\tools" where you want your JDK to be and setup manually JAVA_HOME and PATH to point to your JDK dir and its BIN subdir.
查看更多
forever°为你锁心
5楼-- · 2020-02-07 18:15

I believe this at least used to be feasible to a limited extent with earlier versions of Java - I don't know if it still is.

Most of the registry entries are used for things like browser plugins, as you mentioned in the question. If you just want to be able to run Java (e.g. from a batch file), that's one thing - but really installing it is a different matter. Even if you're just wanting to run it, you'll need to be careful to always explicitly use the one you intend, rather than using the installed one accidentally for part of your application.

What's your actual use case? Do you actually need a browser plugin? What aspect of the configuration are you interested in? A lot of the control panel configuration is to do with updates and browser integration. Many other aspects can be controlled using command line options to set specific system properties.

查看更多
forever°为你锁心
6楼-- · 2020-02-07 18:18

If you just want to have the JDK (JRE) files, you can run the installer within sandboxie. Once installed in the sandbox, just copy the files from c:\sandbox and you are done.

I'm using this to compile and run legacy java applications which cannot be migrated easily to a newer version of java. I can point Eclispe to this JDKs and tell it to be compliant to Java 1.3.

查看更多
再贱就再见
7楼-- · 2020-02-07 18:26

Just down load the Windows server version of Java from the Oracle downloads page. Setup JAVA_HOME and PATH variables on your own.

查看更多
登录 后发表回答