When trying to use the Linux version of Oracle\'s JDK on the latest Windows 10 build having support for bash, I am running into a problem with the prompt hanging whenever at
I used the script given by @fieldju but he missed some things that the script depends on, and also copy/pasting the contents results in having windows line endings/carriage returns (/r
) which will need replacing to linux returns. Also, I found it a lot more straightforward to download the zips needed first and put them alongside the script. Here's a full list of what I did:
bash
, type sudo apt-get install zip unzip
to make sure unzip/zip is installed on your bash
consolebash
NOTE: don't change the file name to ensure it works with the scriptjava_install_predownloaded.sh
in the same folder alongside the zips:Script:
#!/bin/bash
# Extract the archive
tar -xzvf jdk-*.tar.gz
# mk the jvm dir
sudo mkdir -p /usr/lib/jvm
# move the server jre
sudo mv jdk1.8* /usr/lib/jvm/oracle_jdk8
# install unlimited strength policy
mv UnlimitedJCEPolicyJDK8/local_policy.jar /usr/lib/jvm/oracle_jdk8/jre/lib/security/
mv UnlimitedJCEPolicyJDK8/US_export_policy.jar /usr/lib/jvm/oracle_jdk8/jre/lib/security/
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/oracle_jdk8/jre/bin/java 2000
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/oracle_jdk8/bin/javac 2000
sudo echo "export J2SDKDIR=/usr/lib/jvm/oracle_jdk8
export J2REDIR=/usr/lib/jvm/oracle_jdk8/jre
export PATH=$PATH:/usr/lib/jvm/oracle_jdk8/bin:/usr/lib/jvm/oracle_jdk8/db/bin:/usr/lib/jvm/oracle_jdk8/jre/bin
export JAVA_HOME=/usr/lib/jvm/oracle_jdk8
export DERBY_HOME=/usr/lib/jvm/oracle_jdk8/db" | sudo tee -a /etc/profile.d/oraclejdk.sh
This code is a modified version from @fieldju which assumes the zips are already downloaded and in the same folder as this .sh
file
because the file has the windows carriage returns you need to ensure they are replaced, so in bash
navigate to where you saved java_install_predownloaded.sh
and run the following command:
sed 's/^M$//' java_install_predownloaded.sh > java_install_predownloaded_unix.sh
I also then ran the following to ensure there are definitely no line endings from windows:
sed 's/\r$//' java_install_predownloaded_unix.sh > java_install_predownloaded_unix_final.sh
java_install_predownloaded_unix_final.sh
will be in the folder which is our 'cleaned' version without the windows line endings, so you just need to execute ./java_install_predownloaded_unix_final.sh
in bash
and watch the magic happen. Hey Presto you now have java installed on your bash instance on windows!