diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 0000000..924a0fd --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,3 @@ +tasks: + - init: echo "I hope you realized that GitPod is the last needed thing in Termux packages development and you have no point in being here, right?" +image: gitpod/workspace-full diff --git a/README.md b/README.md index 7e25fab..37cbcdf 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,25 @@ +[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code%20(for%20some%20reason)-blue?logo=gitpod)](https://gitpod.io/#https://github.com/MasterDevX/Termux-Java) + # Termux Java + ### Information -This script will install Java in Termux.
-Libraries compiled by Hax4us, script written by Hax4us and MasterDevX. + +This script will install Java in Termux. + +Libraries compiled by [Hax4us](https://github.com/Hax4us "Hax4us's GitHub profile"), scripts written by [Hax4us](https://github.com/Hax4us "Hax4us's GitHub profile"), [MasterDevX](https://github.com/MasterDevX "MasterDevX's GitHub profile") and [Guzio](https://github.com/GuzioMG "Guzio's GitHub profile"), with some *very, very tiny* help from [Harshiv-Patel](https://Harshiv-Patel "he changed like... one thing"). ### How to use -To install Java, open Termux and execute the following command:
+ +To install Java, open Termux and execute the following command: + ```pkg install wget && wget https://raw.githubusercontent.com/MasterDevX/java/master/installjava && bash installjava``` +> Eventually, run ```wget https://raw.githubusercontent.com/MasterDevX/java/master/installjava && bash installjava``` to install Java if you arleady have ```wget``` installed. + +> Or just ```bash installjava``` if you have the script arleady downloaded for some reason. + +When installed, run ```java -version``` to check, if it's correcty installed (i.e. if it throws command not found error, it's clearly not.) + After that you can run Java using ```java``` command. + +We also provide an uninstaller, but since I'm writing this while making that script, there's no way I can attach a command here, as I need a link for that. Anyway, look for ```uninstall_java.sh``` in repo's home. \ No newline at end of file diff --git a/installjava b/installjava old mode 100644 new mode 100755 index b5e34c0..2183676 --- a/installjava +++ b/installjava @@ -1,17 +1,24 @@ #!/data/data/com.termux/files/usr/bin/bash +#Setup +set -e shopt -s expand_aliases alias ee='echo -e' + +#Greetings echo ee "\e[93mThis script will install Java in Termux." ee "\e[93mLibraries compiled by \e[32mHax4us\e[93m, script written by \e[32mHax4us \e[93mand \e[32mMasterDevX\e[93m." echo + +#Checking for existing Java installation if [ -e $PREFIX/bin/java ] then ee "\e[32mJava is already installed!" echo exit else + #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. case `dpkg --print-architecture` in aarch64) archname="aarch64"; tag="v8" ;; @@ -26,20 +33,33 @@ else *) ee "\e[91mERROR: Unknown architecture."; echo; exit ;; esac - ee "\e[32m[*] \e[34mDownloading JDK-8 (~70Mb) for ${archname}..." + + #Actual installation + ee "\e[32m[*] \e[34mDownloading JDK-8 (~70Mb) for ${archname}... ๐Ÿ•›This will take some time, so better make a coffee.๐Ÿ•›" wget https://github.com/Hax4us/java/releases/download/${tag}/jdk8_${archname}.tar.gz -q + ee "\e[32m[*] \e[34mMoving JDK to system..." mv jdk8_${archname}.tar.gz $PREFIX/share + ee "\e[32m[*] \e[34mExtracting JDK..." cd $PREFIX/share tar -xhf jdk8_${archname}.tar.gz - ee "\e[32m[*] \e[34mMoving Java wrapper scripts to bin..." - mv bin/* $PREFIX/bin + + ee "\e[32m[*] \e[34mSeting-up %JAVA_HOME%..." + export JAVA_HOME=$PREFIX/share/jdk8 + echo "export JAVA_HOME=$PREFIX/share/jdk8" >> $HOME/.profile + + ee "\e[32m[*] \e[34mCoping Java wrapper scripts to bin..." + #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. + cp bin/* $PREFIX/bin + ee "\e[32m[*] \e[34mCleaning up temporary files..." rm -rf $HOME/installjava rm -rf $PREFIX/share/jdk8_${archname}.tar.gz rm -rf $PREFIX/share/bin + echo ee "\e[32mJava was successfully installed!\e[39m" + echo "Enjoy your new, tasty Java :D (and a coffee, if you didn't drink it yet)" echo fi diff --git a/openjdk/java b/openjdk/java index e30ab0f..fb936d4 100755 --- a/openjdk/java +++ b/openjdk/java @@ -2,8 +2,8 @@ #export LD_LIBRARY_PATH=/data/data/per.pqy.apktool/apktool/lix #in some targets,LD_PRELOAD will cause a error. export LD_PRELOAD= -export LD_LIBRARY_PATH=/data/data/com.termux/files/home/java/openjdk/lib/arm:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH=$HOME/java/openjdk/lib/arm:$LD_LIBRARY_PATH #umask 000 #cd /data/data/per.pqy.apktool/apktool #echo $$ > pid -exec /data/data/com.termux/files/home/java/openjdk/bin/java -Xmx1024m "$@" +exec $HOME/java/openjdk/bin/java -Xmx1024m "$@" diff --git a/uninstall_java.sh b/uninstall_java.sh new file mode 100644 index 0000000..02c041f --- /dev/null +++ b/uninstall_java.sh @@ -0,0 +1,37 @@ +#!/data/data/com.termux/files/usr/bin/bash + +#Setup +shopt -s expand_aliases +alias ee='echo -e' + +#Greetings +echo +ee "\e[93mThis script will uninstall Java from Termux." +echo + +#Checking for existing Java installation +if [ ! -e $PREFIX/bin/java ] +then + ee "\e[32mJava is not installed!" + echo + exit +else + #Actual uninstallation + ee "\e[32m[*] \e[34mUnseting %JAVA_HOME%..." + unset JAVA_HOME=$PREFIX/share/jdk8 + echo "WARNING! THIS SCRIPT WILL UNSET THE %JAVA_HOME% ONLY TEMPORARILY! I STRONGLY RECOMEND YOU TO REMOVE \"export JAVA_HOME=$PREFIX/share/jdk8\" LINE FROM YOUR \"$HOME/.profile\" SETUP FILE, AS NOT DOING THAT WILL CAUSE PROBLEMS IN SOME APPS!" + + ee "\e[32m[*] \e[34mRemoving Java..." + rm -drf $PREFIX/share/jdk8 + rm $PREFIX/bin/jar + rm $PREFIX/bin/jarsigner + rm $PREFIX/bin/java + rm $PREFIX/bin/javac + rm $PREFIX/bin/javadoc + rm $PREFIX/bin/javah + rm $PREFIX/bin/javap + + echo + ee "\e[32mJava was successfully uninstalled!\e[39m" + echo +fi