Skip to content

Commit 1c41158

Browse files
authored
Merge pull request #18 from GuzioMG/master
Added an uninstaller and some other cool stuff.
2 parents d7bcc63 + df7f167 commit 1c41158

File tree

5 files changed

+82
-8
lines changed

5 files changed

+82
-8
lines changed

.gitpod.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
tasks:
2+
- 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?"
3+
image: gitpod/workspace-full

README.md

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1+
[![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+
13
# Termux Java
4+
25
### Information
3-
This script will install Java in Termux.</br>
4-
Libraries compiled by <a href="https://github.com/Hax4us">Hax4us</a>, script written by <a href="https://github.com/Hax4us">Hax4us</a> and <a href="https://github.com/MasterDevX">MasterDevX</a>.
6+
7+
This script will install Java in Termux.
8+
9+
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").
510

611
### How to use
7-
To install Java, open Termux and execute the following command:</br>
12+
13+
To install Java, open Termux and execute the following command:
14+
815
```pkg install wget && wget https://raw.githubusercontent.com/MasterDevX/java/master/installjava && bash installjava```
916

17+
> Eventually, run ```wget https://raw.githubusercontent.com/MasterDevX/java/master/installjava && bash installjava``` to install Java if you arleady have ```wget``` installed.
18+
19+
> Or just ```bash installjava``` if you have the script arleady downloaded for some reason.
20+
21+
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.)
22+
1023
After that you can run Java using ```java``` command.
24+
25+
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.

installjava

+22-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
#!/data/data/com.termux/files/usr/bin/bash
22

3+
#Setup
34
shopt -s expand_aliases
45
alias ee='echo -e'
6+
7+
#Greetings
58
echo
69
ee "\e[93mThis script will install Java in Termux."
710
ee "\e[93mLibraries compiled by \e[32mHax4us\e[93m, script written by \e[32mHax4us \e[93mand \e[32mMasterDevX\e[93m."
811
echo
12+
13+
#Checking for existing Java installation
914
if [ -e $PREFIX/bin/java ]
1015
then
1116
ee "\e[32mJava is already installed!"
1217
echo
1318
exit
1419
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.
1521
case `dpkg --print-architecture` in
1622
aarch64)
1723
archname="aarch64"; tag="v8" ;;
@@ -26,20 +32,33 @@ else
2632
*)
2733
ee "\e[91mERROR: Unknown architecture."; echo; exit ;;
2834
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.🕛"
3038
wget https://github.com/Hax4us/java/releases/download/${tag}/jdk8_${archname}.tar.gz -q
39+
3140
ee "\e[32m[*] \e[34mMoving JDK to system..."
3241
mv jdk8_${archname}.tar.gz $PREFIX/share
42+
3343
ee "\e[32m[*] \e[34mExtracting JDK..."
3444
cd $PREFIX/share
3545
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+
3855
ee "\e[32m[*] \e[34mCleaning up temporary files..."
3956
rm -rf $HOME/installjava
4057
rm -rf $PREFIX/share/jdk8_${archname}.tar.gz
4158
rm -rf $PREFIX/share/bin
59+
4260
echo
4361
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)"
4463
echo
4564
fi

openjdk/java

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#export LD_LIBRARY_PATH=/data/data/per.pqy.apktool/apktool/lix
33
#in some targets,LD_PRELOAD will cause a error.
44
export LD_PRELOAD=
5-
export LD_LIBRARY_PATH=/data/data/com.termux/files/home/java/openjdk/lib/arm:$LD_LIBRARY_PATH
5+
export LD_LIBRARY_PATH=$HOME/java/openjdk/lib/arm:$LD_LIBRARY_PATH
66
#umask 000
77
#cd /data/data/per.pqy.apktool/apktool
88
#echo $$ > pid
9-
exec /data/data/com.termux/files/home/java/openjdk/bin/java -Xmx1024m "$@"
9+
exec $HOME/java/openjdk/bin/java -Xmx1024m "$@"

uninstall_java.sh

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/data/data/com.termux/files/usr/bin/bash
2+
3+
#Setup
4+
shopt -s expand_aliases
5+
alias ee='echo -e'
6+
7+
#Greetings
8+
echo
9+
ee "\e[93mThis script will uninstall Java from Termux."
10+
echo
11+
12+
#Checking for existing Java installation
13+
if [ ! -e $PREFIX/bin/java ]
14+
then
15+
ee "\e[32mJava is not installed!"
16+
echo
17+
exit
18+
else
19+
#Actual uninstallation
20+
ee "\e[32m[*] \e[34mUnseting %JAVA_HOME%..."
21+
unset JAVA_HOME=$PREFIX/share/jdk8
22+
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!"
23+
24+
ee "\e[32m[*] \e[34mRemoving Java..."
25+
rm -drf $PREFIX/share/jdk8
26+
rm $PREFIX/bin/jar
27+
rm $PREFIX/bin/jarsigner
28+
rm $PREFIX/bin/java
29+
rm $PREFIX/bin/javac
30+
rm $PREFIX/bin/javadoc
31+
rm $PREFIX/bin/javah
32+
rm $PREFIX/bin/javap
33+
34+
echo
35+
ee "\e[32mJava was successfully uninstalled!\e[39m"
36+
echo
37+
fi

0 commit comments

Comments
 (0)