You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In termux I use a shell script that replaces java, cf. description "workaround for having java in termux" below. It works incredibly well. At its core is the command proot -R $UBUNTU java "$@"
The only limitation is that I would like to mount some more directories that are not included by the -R switch.
I tried to use proot-distro instead of proot with the following command in the "java" script: proot-distro login ubuntu-20.04 -- java "$@"
When I run a simple command like java --version this works, too, however I get error messages when I pass lists of quoted arguments.
Here is an example output of a java call that works fine, when I use proot -R $UBUNTU java "$@":
Starting new CIDER session ...
[nREPL] Starting server via /data/data/com.termux/files/usr/var/lib/proot-distro/installed-rootfs/ubuntu-20.04/usr/bin/lein update-in :dependencies conj \[nrepl\ \"0.8.2\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.25.4\"\] -- repl :headless :host localhost
[nREPL] server started on 40408
[nREPL] Establishing direct connection to localhost:40408 ...
[nREPL] Direct connection to localhost:40408 established
Here is an example error, when I use proot-distro login ubuntu-20.04 -- java "$@":
Here is an example error, when I use proot-distro login ubuntu-20.04 -- java "\"$@\"" (escaped quotes around $@) :
Starting new CIDER session ...
[nREPL] Starting server via /data/data/com.termux/files/usr/var/lib/proot-distro/installed-rootfs/ubuntu-20.04/usr/bin/lein update-in :dependencies conj \[nrepl\ \"0.8.2\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.25.4\"\] -- repl :headless :host localhost
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server:
Error occurred during initialization of VM
java.nio.charset.IllegalCharsetNameException: UTF-8 -Dmaven.wagon.http.ssl.easy=false -Dmaven.wagon.rto=10000 -Xbootclasspath/a:/data/data/com.termux/files/home/.lein/self-installs/leiningen-2.9.4-standalone.jar -Xverify:none -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Dleiningen.input-checksum= -Dleiningen.original.pwd=/data/data/com.termux/files/home/cloj-projects/clojupyter-fiddle -Dleiningen.script=/data/data/com.termux/files/usr/var/lib/proot-distro/installed-rootfs/ubuntu-20.04/usr/bin/lein -classpath /data/data/com.termux/files/home/.lein/self-installs/leiningen-2.9.4-standalone.jar clojure.main -m leiningen.core.main update-in :dependencies conj [nrepl
at java.nio.charset.Charset.checkName(java.base/Charset.java:308)
at java.nio.charset.Charset.lookup2(java.base/Charset.java:482)
at java.nio.charset.Charset.lookup(java.base/Charset.java:462)
at java.nio.charset.Charset.defaultCharset(java.base/Charset.java:608)
at sun.nio.cs.StreamEncoder.forOutputStreamWriter(java.base/StreamEncoder.java:56)
at java.io.OutputStreamWriter.<init>(java.base/OutputStreamWriter.java:110)
at java.io.PrintStream.<init>(java.base/PrintStream.java:110)
at java.io.PrintStream.<init>(java.base/PrintStream.java:148)
at java.lang.System.newPrintStream(java.base/System.java:1898)
at java.lang.System.initPhase1(java.base/System.java:1974)
And finally, here is an example error, when I use proot-distro login ubuntu-20.04 -- java $@ (no quotes around $@):
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):
(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:
In termux I use a shell script that replaces java, cf. description "workaround for having java in termux" below. It works incredibly well. At its core is the command
proot -R $UBUNTU java "$@"
The only limitation is that I would like to mount some more directories that are not included by the -R switch.
I tried to use proot-distro instead of proot with the following command in the "java" script:
proot-distro login ubuntu-20.04 -- java "$@"
When I run a simple command like
java --version
this works, too, however I get error messages when I pass lists of quoted arguments.Here is an example output of a java call that works fine, when I use
proot -R $UBUNTU java "$@"
:Here is an example error, when I use
proot-distro login ubuntu-20.04 -- java "$@"
:Here is an example error, when I use proot-distro login ubuntu-20.04 -- java "\"$@\"" (escaped quotes around $@) :
And finally, here is an example error, when I use proot-distro login
ubuntu-20.04 -- java $@
(no quotes around $@):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):
Within the ubuntu distro install the openjdk:
(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:
From the fish prompt you can do this using the following command:
(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.
Originally posted by @ronnac in termux/termux-packages#324 (comment)
The text was updated successfully, but these errors were encountered: