|
1 | 1 | #!/data/data/com.termux/files/usr/bin/bash
|
2 | 2 |
|
| 3 | +#Setup |
3 | 4 | shopt -s expand_aliases
|
4 | 5 | alias ee='echo -e'
|
| 6 | + |
| 7 | +#Greetings |
5 | 8 | echo
|
6 | 9 | ee "\e[93mThis script will install Java in Termux."
|
7 | 10 | ee "\e[93mLibraries compiled by \e[32mHax4us\e[93m, script written by \e[32mHax4us \e[93mand \e[32mMasterDevX\e[93m."
|
8 | 11 | echo
|
| 12 | + |
| 13 | +#Checking for existing Java installation |
9 | 14 | if [ -e $PREFIX/bin/java ]
|
10 | 15 | then
|
11 | 16 | ee "\e[32mJava is already installed!"
|
12 | 17 | echo
|
13 | 18 | exit
|
14 | 19 | else
|
| 20 | + #Checking, whether is someone trying to cheat and simplyfy their installation it on Linux (i.e. x86 (not listad, as you can see) machine) using this script, which have no reason to work. |
15 | 21 | case `dpkg --print-architecture` in
|
16 | 22 | aarch64)
|
17 | 23 | archname="aarch64"; tag="v8" ;;
|
|
26 | 32 | *)
|
27 | 33 | ee "\e[91mERROR: Unknown architecture."; echo; exit ;;
|
28 | 34 | esac
|
29 |
| - ee "\e[32m[*] \e[34mDownloading JDK-8 (~70Mb) for ${archname}..." |
| 35 | + |
| 36 | + #Actual installation |
| 37 | + ee "\e[32m[*] \e[34mDownloading JDK-8 (~70Mb) for ${archname}... 🕛This will take some time, so better make a coffee.🕛" |
30 | 38 | wget https://github.com/Hax4us/java/releases/download/${tag}/jdk8_${archname}.tar.gz -q
|
| 39 | + |
31 | 40 | ee "\e[32m[*] \e[34mMoving JDK to system..."
|
32 | 41 | mv jdk8_${archname}.tar.gz $PREFIX/share
|
| 42 | + |
33 | 43 | ee "\e[32m[*] \e[34mExtracting JDK..."
|
34 | 44 | cd $PREFIX/share
|
35 | 45 | tar -xhf jdk8_${archname}.tar.gz
|
36 |
| - ee "\e[32m[*] \e[34mMoving Java wrapper scripts to bin..." |
37 |
| - mv bin/* $PREFIX/bin |
| 46 | + |
| 47 | + ee "\e[32m[*] \e[34mSeting-up %JAVA_HOME%..." |
| 48 | + export JAVA_HOME=$PREFIX/share/jdk8 |
| 49 | + echo "export JAVA_HOME=$PREFIX/share/jdk8" >> $HOME/.profile |
| 50 | + |
| 51 | + ee "\e[32m[*] \e[34mCoping Java wrapper scripts to bin..." |
| 52 | + #I'm not 100% sure, but getting rid of bin contnent MAY cause some issues with %JAVA_HOME%, thus it's no longer moved - copied instead. Sorry to everyone short on storage. |
| 53 | + cp bin/* $PREFIX/bin |
| 54 | + |
38 | 55 | ee "\e[32m[*] \e[34mCleaning up temporary files..."
|
39 | 56 | rm -rf $HOME/installjava
|
40 | 57 | rm -rf $PREFIX/share/jdk8_${archname}.tar.gz
|
41 | 58 | rm -rf $PREFIX/share/bin
|
| 59 | + |
42 | 60 | echo
|
43 | 61 | ee "\e[32mJava was successfully installed!\e[39m"
|
| 62 | + echo "Enjoy your new, tasty Java :D (and a coffee, if you didn't drink it yet)" |
44 | 63 | echo
|
45 | 64 | fi
|
0 commit comments