termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.08k stars 3k forks source link

Package request: javac/jar/jdk #324

Closed ghost closed 3 years ago

ghost commented 8 years ago

Please add the Java compilers (java, javac, jar, etc.)

ghost commented 6 years ago

AWESOME! Thanks! I love Arch Linux, this helps immensely.

On Fri, Nov 10, 2017, 4:25 AM S D Rausty notifications@github.com wrote:

@AravK https://github.com/aravk Java is available through: TermuxArch https://github.com/sdrausty/TermuxArch

Now you can install Arch Linux in Termux 📲 on your smartphone and tablet. More information at https://sdrausty.github.io/TermuxArch

Java is available through https://sdrausty.github.io/TermuxArch/ Just follow the easy install instructions at https://sdrausty.github.io/TermuxArch/docs/docs/install or simply copy and paste the following into your Termux window:

cd && git clone https://github.com/sdrausty/TermuxArch ./TermuxArch/setupTermuxArch.sh

Read more about the Arch Linux package manager at duckduckgo arch+linux+install+java+pacman. https://duckduckgo.com/?q=arch+linux+install+java+pacman&atb=v90-2__&t=cros&ia=qa

To install java run pacman -Syy; pacman -Su; pacman -S jdk8-openjdk

[image: screenshot_20171109-220204] https://user-images.githubusercontent.com/27742457/32641053-cedfdcfe-c599-11e7-9c73-b185e70e9c6a.png [image: screenshot_20171109-222326] https://user-images.githubusercontent.com/27742457/32641590-d5541d4a-c59c-11e7-8855-e151bc217acc.png

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/termux/termux-packages/issues/324#issuecomment-343364440, or mute the thread https://github.com/notifications/unsubscribe-auth/ARILTo9TZNzA9CfXca0rV6UTzcfHDDPBks5s08IbgaJpZM4I2K8f .

--

AK

EralpCelebi commented 6 years ago

That is awsome , I have been waiting this for months now.

SDRausty commented 6 years ago

Use useradd username. Then cp -r arch/root/ arch/username. Finally su - username and similar to login as user, not the root account of your Arch Linux in Termux installation and similar.

From https://github.com/sdrausty/TermuxArch/issues/26 "...use makepkg to build packages" which should be useful for user and permission issues with Termux-app and Termux-packages.

Please direct PRoot in Termux issues https://github.com/termux/proot here. Comments regarding setupTermuxArch.sh should be directed to https://github.com/sdrausty/TermuxArch/issues. setupTermuxArch.sh creates system information when requested. Run setupTermuxArch.sh --sysinfo and post this information along with your input and complete output if necessary. Also include a screenshot if it will help in resolving the issue.

@AravK @EralpCelebi Thank you for your compliments! Hopefully you are inspired with Arch Linux in Termux PRoot and Termux on device as well as I am. A new website regarding Arch Linux in Termux PRoot is being built at https://sdrausty.github.io/TermuxPovray/ regarding https://github.com/termux/termux-packages/issues/202 Package request: povray.

scifi_demo

Created on device in Termux from https://github.com/termux/termux-packages/issues/202 Package request: povray.

TheBrokenRail commented 5 years ago

If you use DexClassLoader make sure to prevent System.exit calls from crashing the whole app.

lionheart878 commented 5 years ago

Oracle jdk8 install on termux:---- 1)(Termux updare and upgrade) $ apt update && upgrade -y

2)(package Install) $ pkg install $ pkg install git $ pkg install lftp proot

3)(Jdk download on Oracle site, hflt.tar.gz type jdk file download) http://www.oracle.com/technetwork

then code paste in termux

$ cd && git clone https://github.com/sdrausty/TermuxArch

$ ./TermuxArch/setupTermuxArch.sh Sometime consume to installation after installation:-

$ exit

$ startarch

$ rm -r TermuxArch

$ cd arch

5)(copy java file sdcard to arch terminal) go to mobile setting ----> install apps ---> termux access storage permissions ----"on"... then paste the code on termux $ cp /sdcard/Download/jdk-8u212-linux-arm64-vfp-hflt.tar.gz .

6)(then java install in arch go to file location ware you java install and paste the code) $ pacman -S sudo -y $ sudo tar xvzf jdk-8u212-linux-arm64-vfp-hflt.tar.gz

7)(java path sate) $ sudo nano /etc/profile.d/jdk1.8.0_212.sh

8)(then nano pad open then type java location) export JAVA_HOME="/jdk1.8.0_212" export PATH="$PATH:${JAVA_HOME}/bin"

(type alt +x ---> y "To save" then press enter that's all) $ exit $ exit Reopen termux $ startarch $ cd arch

$ echo $JAVA_HOME $ echo $PATH

Then Type "java -version" Java(TM) SE Runtime Environment (build 1.8.0_212-b10) Java HotSpot(TM) 64-Bit Server VM (build 25.212-b10, mixed mode)

CRamsan commented 5 years ago

Hello eveyone. This is just a poke to see if there is any movement on this topic. It seems like some people are using ejc as a replacement for javac. I will be reading and catching up on how to compile the JDK.

Harshiv-Patel commented 5 years ago

@CRamsan , many of the most used tools in JDK like javac, javah etc are written in java, that are not as difficult to bring to android as porting the runtime environment, which is written in native languages and APIs per OS.

ghost commented 5 years ago

many of the most used tools in JDK like javac, javah etc are written in java

Significant part of OpenJDK is written in C++ and has problems when compiling with clang from Android NDK (starting from NDK r18).

Harshiv-Patel commented 5 years ago

I suppose a simple yet difficult way to deal with such a problem is to make a list of problematic functions and deal them one by one, handling all the API differences ?

alexandre-mbm commented 4 years ago

@CRamsan

It seems like some people are using ejc as a replacement for javac.

JavaOnTermux.sh

I will be reading and catching up on how to compile the JDK.

Did you go beyond that?

Mhowser commented 4 years ago

Hello everyone, just wanted to ask if there has been any new development on this.

ghost commented 4 years ago

there has been any new development on this.

If package request tagged as help wanted, then Termux maintainers can't handle it. Pull requests are wanted.

Mhowser commented 4 years ago

Ah I didn't notice that, thanks for the info.

artdeell commented 3 years ago

So, i highly suggest looking at Minecraft JE on Android launchers. They managed to get JRE 8 working on android. Will it help, though?

ghost commented 3 years ago

They managed to get JRE 8 working on android. Will it help, though?

The only thing that will help is a submission of script and patches for cross-compiling JDK for Android OS (Termux). Until that, JDK may never be ported.

Read my previous comment.

artdeell commented 3 years ago

https://github.com/AOF-Dev/openjdk-aarch64-jdk8u-androidport Don't know about building though

ghost commented 3 years ago

@artdeell Your repository link is neither official OpenJDK sources nor has anything that will help to create a proper build script for Termux.

See https://github.com/termux/termux-packages/tree/667fce5a65eaf163ed05a65dce9fb0d587b46301/disabled-packages/openjdk-9-jre-headless (but updated at least to Java 11 & fixed for latest Clang-based NDK) to know what we are looking for.

hltdev8642 commented 3 years ago

check out my fork of the run_java repository (that uses dx/ecj).

My version comes from a fork which added support for class filenames (.class instead of .dex), but didn't support multiple input arguments.

I was able to get this fixed and working with multi-arg support (aka: javac *.java or javac fileA.java fileB.java ... fileN. java

of course it's not going to make actual compiled Java .class files run, but it does function identically when compiling/running (tab autocompetion works)

idn if anyone is even still thinking about / cares about this anymore, but maybe it will make someone happy 😊

Mhowser commented 3 years ago

If it can run a minecraft server then it is good enough for me!

On Wed, Nov 4, 2020 at 11:53 AM hltdev8642 notifications@github.com wrote:

check out my fork https://github.com/hltdev8642/run_java of the run_java https://github.com/zaoqi-clone/run_java repository (that uses dx/ecj).

My version comes from a fork which added support for class filenames (.class instead of .dex), but didn't support multiple input arguments.

I was able to get this fixed and working with multi-arg support (aka: javac *.java or javac fileA.java fileB.java ... fileN. java

of course it's not going to make actual compiled Java .class files run, but it does function identically when compiling/running (tab autocompetion works)

idn if anyone is even still thinking about / cares about this anymore, but maybe it will make someone happy 😊

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/termux/termux-packages/issues/324#issuecomment-721941486, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFYTD5HUOZAZ4J4MB4WAAKTSOGWMVANCNFSM4CGYV4PQ .

hltdev8642 commented 3 years ago

Maybe!!!, however I doubt it as I dont think that it deals with jar files (and you couldnt just extract it, as the method being used in the run_java repo is basically just creating .dex files and renaming them so they basically just look "like" a standard java class file.

If you want to run a minecraft server on Android that's not all too hard

the thing is, is that it is not really running java/javac in the traditional way, but just linking filenames to the android binaries dx and ecj (compile dex (android-formatted) src code).

but good luck, who knows it may work :D

ronnac commented 3 years ago

workaround for having java in termux

TL;DR I create an ubuntu proot, where I install the openjdk. Back in termux I create a bash script named "java" which, when called, forwards to the real java within the ubuntu proot by using the proot command.

How Set up the ubuntu-20.04 proot (more info here):

pkg install proot-distro
proot-distro list #(check ubuntu versions available)
proot-distro install ubuntu-20.04
proot-distro login ubuntu-20.04

Within the ubuntu distro install the openjdk:

apt update
apt upgrade
apt install openjdk-8-jdk

(I suppose this also works with later versions of the openjdk.)

Return to termux (press Ctrl-D)

Add the following line in ~/.bashrc export UBUNTU=$PREFIX/var/lib/proot-distro/installed-rootfs/ubuntu-20.04/ From the bash or fish prompt you can do this using the following command: echo "export UBUNTU=\$PREFIX/var/lib/proot-distro/installed-rootfs/ubuntu-20.04/" >> ~/.bashrc Restart the termux session so that .bashrc is executed and the variable $UBUNTU is set.

Create the script file "java" in ~/../usr/bin/ with the following content:

#!/usr/bin/bash
unset LD_PRELOAD
proot -R $UBUNTU java "$@"

From the fish prompt you can do this using the following command:

echo "#!/usr/bin/bash
unset LD_PRELOAD
proot -R \$UBUNTU java \"\$@\" " >> ~/../usr/bin/java

(I don't know how to do this from the bash prompt)

For more information about the proot command, check the manual.

Make the script "java" executable: chmod 777 ../usr/bin/java

You can now call java with arguments from termux. I suppose you can do the same trick for javac.

I would be happy to hear about your suggestions for improvement.

USMP-lancer commented 3 years ago

workaround for having java in termux

TL;DR I create an ubuntu proot, where I install the openjdk. Back in termux I create a bash script named "java" which, when called, forwards to the real java within the ubuntu proot by using the proot command.

How Set up the ubuntu-20.04 proot (more info here):

pkg install proot-distro
proot-distro list #(check ubuntu versions available)
proot-distro install ubuntu-20.04
proot-distro login ubuntu-20.04

Within the ubuntu distro install the openjdk:

apt update
apt upgrade
apt install openjdk-8-jdk

(I suppose this also works with later versions of the openjdk.)

Return to termux (press Ctrl-D)

Add the following line in ~/.bashrc export UBUNTU=$PREFIX/var/lib/proot-distro/installed-rootfs/ubuntu-20.04/ From the bash or fish prompt you can do this using the following command: echo "export UBUNTU=\$PREFIX/var/lib/proot-distro/installed-rootfs/ubuntu-20.04/" >> ~/.bashrc Restart the termux session so that .bashrc is executed and the variable $UBUNTU is set.

Create the script file "java" in ~/../usr/bin/ with the following content:

#!/usr/bin/bash
unset LD_PRELOAD
proot -R $UBUNTU java "$@"

From the fish prompt you can do this using the following command:

echo "#!/usr/bin/bash
unset LD_PRELOAD
proot -R \$UBUNTU java \"\$@\" " >> ~/../usr/bin/java

(I don't know how to do this from the bash prompt)

For more information about the proot command, check the manual.

Make the script "java" executable: chmod 777 ../usr/bin/java

You can now call java with arguments from termux. I suppose you can do the same trick for javac.

I would be happy to hear about your suggestions for improvement.

genius

USMP-lancer commented 3 years ago

the only problem i have is the command is a bit long

USMP-lancer commented 3 years ago

now to compile

hltdev8642 commented 3 years ago

on a sem-related note, the mentioned method linking to proot has worked for me not only with Java/Javac, but also ant and a whole handful of other programs. so props to @ronnac for that :-)

USMP-lancer commented 3 years ago

is it possile to have it open the ubuntu thing on startup?

ghost commented 3 years ago

JDK is available as package openjdk-17.

ronnac commented 3 years ago

That is almost fantastic news; alas:javaError occurred during initialization of VMjava.lang.StackOverflowError        at java.lang.String.(java.base/String.java:224) -------- Original message --------From: Leonid Pliushch @.> Date: 30/07/21 15:41 (GMT+01:00) To: termux/termux-packages @.> Cc: Nick Römer @.>, Mention @.> Subject: Re: [termux/termux-packages] Package request: javac/jar/jdk (#324) JDK is available as package openjdk-17.

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.

Mhowser commented 3 years ago

@ronnac that issue is being worked on. https://github.com/termux/termux-packages/issues/7214