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 4d72e0c..37cbcdf 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,25 @@ -# Java for termux -# Steps -1.mv java/openjdk/java /data/data/com.termux/files/usr/bin +[![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) -2.Now you can execute java +# Termux Java -# Hello I am Lokesh (devil - admin of hax4us channel & website ) +### Information -# This is a try to use java easily in termux plz dont put my hardwork into dustbean by copying my work :D thnx +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: + +```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 6b6ab10..2183676 --- a/installjava +++ b/installjava @@ -1,92 +1,65 @@ #!/data/data/com.termux/files/usr/bin/bash -clear -sleep 0 + +#Setup +set -e shopt -s expand_aliases alias ee='echo -e' -ee " \033[33m----------------------------\033[0m" -ee" \033[36mLokesh:Hax4Us:€|eViL" -ee" \033[33m----------------------------\033[0m" -echo -ee" \033[36mJava Installation Script v1.0" -ee " \033[33m ----------------------------------" -echo -ee " \033[31mDon't take credits :D (Shared libraries are compiled by me)" -ee "\033[33m ------------------------------------" - -arch=`dpkg --print-architecture` -echo "Do you want to continue (y|Y/n|N)" - read yesorno - if [ $yesorno = 'y' -o $yesorno = 'Y' ] ; then - echo "Package size is around 70mb before extraction" +#Greetings echo - else - ee "\033[35mbye bye ... :D\033[0m" - exit -fi - if [ $arch = "aarch64" -o $arch = "arm64" ] ; then - - ee "\033[32m[*] Now wait until jdk-8 is installing ...πŸ•›πŸ•§\033[0m" - echo - -wget https://github.com/Hax4us/java/releases/download/v8/jdk8_aarch64.tar.gz - +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 -ee "\033[32m[*] Moving jdk into system ...\033[0m" -mv jdk8_aarch64.tar.gz $PREFIX/share - -ee "\033[32m[*] Extracting ...\033[0m" -cd $PREFIX/share -tar -xhf jdk8_aarch64.tar.gz - -ee "\033[32m[*] Moving wrapper scripts for java 8\033[0m" -mv bin/* $PREFIX/bin - -ee "\033[34mHappy java :D\033[0m" - - elif [ $arch = "armhf" -o $arch = "armv7l" ]; then - echo "armhf" - ee "\033[32m[*] Now wait until jdk-8 is installing ...πŸ•›πŸ•§\033[0m" - echo - -wget https://github.com/Hax4us/java/releases/download/v8-151/jdk8_arm.tar.gz - -echo -ee "\033[32m[*] Moving jdk into system ...\033[0m" -mv jdk8_arm.tar.gz $PREFIX/share -echo -ee "\033[32m[*] Extracting ...\033[0m" -cd $PREFIX/share -tar -xhf jdk8_arm.tar.gz -echo -ee "\033[32m[*] Moving wrapper scripts for java 8\033[0m" -mv bin/* $PREFIX/bin -rm -rf $PREFIX/share/bin -echo -ee "\033[34mHappy java :D\033[0m" - - - elif [ $arch = "arm" ]; then - ee "\033[32m[*] Now wait until jdk-8 is installing ...πŸ•›πŸ•§\033[0m" - echo - -wget https://github.com/Hax4us/java/releases/download/v8-151/jdk8_arm.tar.gz - -echo -ee "\033[32m[*] Moving jdk into system ...\033[0m" -mv jdk8_arm.tar.gz $PREFIX/share -echo -ee "\033[32m[*] Extracting ...\033[0m" -cd $PREFIX/share -tar -xhf jdk8_arm.tar.gz -echo -ee "\033[32m[*] Moving wrapper scripts for java 8\033[0m" -mv bin/* $PREFIX/bin -rm -rf $PREFIX/share/bin -echo -ee "\033[34mHappy java :D\033[0m" - - else - ee "\033[31munknown architecture :( plz contact @hax4us for more info\033[0m" +#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" ;; + arm64) + archname="aarch64"; tag="v8" ;; + armhf) + archname="arm"; tag="v8-151" ;; + armv7l) + archname="arm"; tag="v8-151" ;; + arm) + archname="arm"; tag="v8-151" ;; + *) + ee "\e[91mERROR: Unknown architecture."; echo; exit ;; + esac + + #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[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