JDK is one of the tool that I need but don't want to install during development. I want to perform some automated tasks to set up a portable development environment (for android development). But downloading and extracting the JDK in a workable state are a bit tricky. Here is what I have performed to automate the process under Windows environment.
To automate the task using Windows batch script, you will need to acquire the following command tools first.
- wget.exe
- 7z.exe and 7z.dll
@echo off
"%~dp0wget.exe" --no-check-certificate -O "%~dp0jdk-7u55-windows-i586.exe" "http://download.oracle.com/otn-pub/java/jdk/7u55-b13/jdk-7u55-windows-i586.exe" --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie"
"%~dp07z.exe" x -y "%~dp0jdk-7u55-windows-i586.exe" -o"%~dp0jdk_1.7.0_55"
"%~dp07z.exe" x -y "%~dp0jdk_1.7.0_55\tools.zip" -o"%~dp0jdk_1.7.0_55"
del "%~dp0jdk_1.7.0_55\tools.zip"
for /r "%~dp0jdk_1.7.0_55" %%x in (*.pack) do "%~dp0jdk_1.7.0_55\bin\unpack200" "%%x" "%%x.jar"
for /r "%~dp0jdk_1.7.0_55" %%y in (*.pack) do ren "%%y" "%%~ny.pack.org"
for /r "%~dp0jdk_1.7.0_55" %%z in (*.pack.jar) do ren "%%z" "%%~nz"
for /r "%~dp0jdk_1.7.0_55" %%a in (*.pack) do ren "%%a" "%%~na.jar"
for /r "%~dp0jdk_1.7.0_55" %%y in (*.pack.org) do del "%%y"
And lastly, double click "getJDK.bat" to start the process. After the process finished, the folder "jdk_1.7.0_55" should contain a workable JDK.
Don't forget to set the JAVA_HOME environment variable to point to your JDK folder and also add the %JAVA_HOME%\bin to the PATH environment in order to use the JDK wherever you are.