I've successfully build an openjdk 11 JDK for my target board (based on Gnueabi ARM).
Then with JDK Jlink I successfully created a custom JRE which I was able to run on my target.
Now I'd like to remote debug with JStatd or JMX, but when I start java with
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8855
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
I got this error
-Dcom.sun.management is not supported in this VM.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
I already created a custom JRE with all the possible Java 11 modules with the command
sudo qemu-arm -L /usr/arm-linux-gnueabi jdk/bin/jlink --no-header-files --no-man-pages --module-path jmods --compress=2 --add-modules java.base,java.compiler,java.datatransfer,java.desktop,java.instrument,java.logging,java.management,java.management.rmi,java.naming,java.net.http,java.prefs,java.rmi,java.scripting,java.se,java.security.jgss,java.security.sasl,java.smartcardio,java.sql,java.sql.rowset,java.transaction.xa,java.xml,java.xml.crypto,jdk.accessibility,jdk.attach,jdk.charsets,jdk.compiler,jdk.crypto.cryptoki,jdk.crypto.ec,jdk.dynalink,jdk.editpad,jdk.hotspot.agent,jdk.httpserver,jdk.jartool,jdk.javadoc,jdk.jcmd,jdk.jconsole,jdk.jdeps,jdk.jdi,jdk.jdwp.agent,jdk.jfr,jdk.jlink,jdk.jshell,jdk.jsobject,jdk.jstatd,jdk.localedata,jdk.management,jdk.management.agent,jdk.management.jfr,jdk.naming.dns,jdk.naming.rmi,jdk.net,jdk.pack,jdk.rmic,jdk.scripting.nashorn,jdk.sctp,jdk.security.auth,jdk.security.jgss,jdk.xml.dom,jdk.zipfs --output jre_all_modules
but I got the same "-Dcom.sun.management is not supported in this VM." error.
Since the target is an embedded board, with restricted amount of RAM, the goal is to got the minimun set of modules needed to run openjdk 11 JMX or JStatd.
Thanks to all in advance
Related
I have a Java application which uses javaFX to process images (using the javafx.scene.image.Image and some related functionality, and instantiating an javafx/embed/swing/JFXPanel object to force JavaFX to initialise). I'm trying to run this application on an Oracle free server running Oracle Linux 8.6 with Oracle Java 1.8.0_351 (OpenJDK and Oracle Java 19 give errors relating to JavaFX not being present). I've compiled my application into a JAR (compiling for Java 1.8.0_301 using Oracle Java on Windows). However, on the server, this doesn't work; I get the exception java.lang.UnsupportedOperationException: Unable to open DISPLAY.
This question's answer suggests using xvfb:
Deploy JavaFX on Ubuntu server without display
I've tried this, but get a "GLX version 1.3 or higher is required" error instead.
Is there a solution for running JavaFX with Oracle Linux?
What I've tried:
I've tried with two different OSes available with Oracle free;
Oracle Linux 8.6
OpenJDK was installed with sudo dnf install java-1.8.0-openjdk-devel.x86_64.
Running the jar gives the NoClassDefFoundError error.
I couldn't work out how to install javafx with dnf on Oracle Linux.
I decided to give Oracle Java a go; OpenJDK was unlinked with sudo unlink /etc/alternatives/java.
The Oracle jdk 19 was downloaded and installed with sudo rpm -ivh jdk-19_linux-x64_bin.rpm. Running the jar (with java -jar MyJar.jar) still gives the same error.
I tried uninstalling that (with sudo dnf remove jdk-19) and openJDK (with sudo dnf remove java) and installing Oracle Java 1.8.0 from a .rpm file. I then get an java.lang.UnsupportedOperationException: Unable to open DISPLAY error.
Xvfb was installed using sudo dnf install xorg-x11-server-Xvfb. xdpyinfo was installed using sudo dnf install xdpyinfo.
Xvfb was started using export DISPLAY=:99 and sudo xdpyinfo -display $DISPLAY > /dev/null || Xvfb $DISPLAY -screen 0 1024x768x16 & (taken from here: https://unix.stackexchange.com/a/297882 )
When running the JAR, I then get the exception
ES2 Prism: Error - GLX extension is not supported
GLX version 1.3 or higher is required
java.lang.UnsupportedOperationException: Internal Error
Canonical Ubuntu 22.04 Minimal
OpenJDK was installed with sudo apt-get install openjdk-8-jdk.
Running the jar gives the NoClassDefFoundError error.
OpenJFX was installed with sudo apt-get install openjfx. Same error.
I tried running the JAR with --module-path argument pointing to /usr/share/openjfx/lib/; --module-path is an unrecognised option with Java 8.
I upgraded to the latest openjdk sudo apt-get install openjdk. After this I'm able to use --module-path.
I tried running the JAR with java --module-path /usr/share/openjfx/lib/ --add-modules javafx.controls,javafx.base,javafx.graphics,javafx.swing -jar MyJar.jar (I'm not sure which modules correspond to which packages...). This causes a java.lang.UnsupportedOperationException: Unable to open DISPLAY error.
I'm trying to run the command sudo apt update on my terminal in MacOS
I'm getting this message in response: The operation couldn’t be completed. Unable to locate a Java Runtime that supports apt. Please visit http://www.java.com for information on installing Java.
I saw a similar question here, however even though I made sure to install the JDK like the solution suggested I'm still getting the same response.
I also tried pasting
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"
export JAVA_HOME="$HOME/.jenv/versions/`jenv version-name`"
Into my .zshrc.save folder and had no luck.
When I run java -version in the terminal this is what I get back:
java version "15.0.2" 2021-01-19
Java(TM) SE Runtime Environment (build 15.0.2+7-27)
Java HotSpot(TM) 64-Bit Server VM (build 15.0.2+7-27, mixed mode, sharing)
20 years ago, java shipped with a tool called apt: Annotation Processor Tool. This tool was obsolete not much later.
What that update-node-js-version is talking about, is a completely and totally unrelated tool: It's the Advanced Package Tool, which is a tool to manage installations on debian and ubuntu - linux distros. You do not want to run this on a mac, and the instructions you found are therefore completely useless: That is how to update node-js on linux. Your machine isn't linux.
Search around for answers involving brew, which is the go-to equivalent of apt on mac. And completely forget about java - this has NOTHING to do with java - that was just a pure coincidence.
Install Homebrew on your Mac Machine
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
For the system Java wrappers to find this JDK, symlink it with
sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
If you need to have openjdk first in your PATH, run:
echo 'export PATH="/usr/local/opt/openjdk/bin:$PATH"' >> ~/.profile
For compilers to find openjdk you may need to set:
export CPPFLAGS="-I/usr/local/opt/openjdk/include"
The below commands worked for me.
First, install the homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then set the Android Studio Java path to the Home(If you have Android Studio). If not then you take the respective Java path & export it to the JAVA Home path.
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home
I have followed the instructions for getting started with codenameone in IntelliJ, yet when I set up my first project, based on the sample app I get this error:
"C:\Program Files\Java\jdk-15.0.1\bin\java.exe" -Xms128m -Xmx1014m -XX:ReservedCodeCacheSize=512m -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50 -XX:CICompilerCount=2 -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -ea -Dsun.io.useCanonCaches=false -Djdk.http.auth.tunneling.disabledSchemes=\"\" -Djdk.attach.allowAttachSelf=true -Djdk.module.illegalAccess.silent=true -Dkotlinx.coroutines.debug=off "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2020.3.1\lib\idea_rt.jar=61544:C:\Program Files\JetBrains\IntelliJ IDEA 2020.3.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\reinp\OneDrive - beuthhs\beuth\Patterns und Frameworks\justtrivia\out\production\justtrivia;C:\Users\reinp\OneDrive - beuthhs\beuth\Patterns und Frameworks\justtrivia\src;C:\Users\reinp\OneDrive - beuthhs\beuth\Patterns und Frameworks\justtrivia\lib\CodenameOne.jar;C:\Users\reinp\OneDrive - beuthhs\beuth\Patterns und Frameworks\justtrivia\JavaSE.jar;native\internal_tmp;lib\impl\cls" com.codename1.impl.javase.Simulator com.patrickreinbold.justtrivia.JustTrivia
Unrecognized VM option 'UseConcMarkSweepGC'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Process finished with exit code 1
I saw that this has to do with Java 8 but in the IntelliJ instructions it says nothing about using Java 8. Is Java 8 always necessary or can codenameone run with Java 15, too?
EDIT:
I have now got it to open by simply copying the first line with the java command and removing the UseConcMarkSweepGC flag, then running it in terminal. But I am still not sure if that is "the correct way" to do it or if something could break along the way now.
Ignore unsupported VM options with another option:
-XX:+IgnoreUnrecognizedVMOptions
This is a problem with the netbeans build script but this isn't really relevant as Codename One only supports Java 8 and Java 11 (at this time) so you should use one of those versions at the moment.
run export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
Homebrew users:
Comment out these lines
# /usr/local/etc/elasticsearch/jvm.options
## GC configuration
#-XX:+UseConcMarkSweepGC
#-XX:CMSInitiatingOccupancyFraction=75
#-XX:+UseCMSInitiatingOccupancyOnly
Then if you get
Invalid -Xlog option '-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m'
Update the logging file path
# JDK 9+ GC logging
9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m
to
# JDK 9+ GC logging
9-:-Xlog:gc*,gc+age=trace,safepoint:file=/usr/local/var/log/elasticsearch/gc.log:utctime,pid,tags:filecount=32,filesize=64m
Sources
Brew installed Elasticsearch 7.9.2 failing on macOS
https://stackoverflow.com/a/57993824/2237510
I'm trying to run this command on my linux machine:
java -noverify -Xbootclasspath/p:burp-loader-keygen-2020_2.jar -jar burpsuite_pro_v2020.2.jar
and i keep getting these errors:
-Xbootclasspath/p is no longer a supported option.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
I tried to install again these versions:
sudo apt update
sudo apt install default-jdk -y
sudo apt install default-jre -y
But i kept getting the same error over and over, any solution or help or suggestion?
You are running the Burp Suite JAR file the wrong way.
If this is an older version of Burp Suite, you must use Java 8 which still supports the -Xbootclasspath option. Note it is not sufficient to simply install Java 8. You need to make sure that java -version says it is Java 8, or use the full path to the Java 8 version of the java
command.
This won't work with Burp Suite 2020.4 or later.
Conversely, if you are using Burp Suite 2020.4 or later, then you need to use Java 9 or later, and you need to run like this:
java -jar -Xmx4g /path/to/burp.jar
Source:
Burp Suite Releases: Professional / Community 2020.4
Launching Burp Suite from the command line (as of the time of writing this answer).
This question already has an answer here:
JavaFx Ensemble on Raspberry pi
(1 answer)
Closed 7 years ago.
I have downloaded the latest OS for the pi from here http://downloads.raspberrypi.org/raspbian_latest
Then i have downloaded the latest Java JDK to run my JavaFX application from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html and selected the Hard Flat v6/v7 file.
I have transferred and unzipped the JavaJDK onto my Pi.
Now if i execute this command on my local machine, my application starts
Java -jar program_name.jar
But if i run the same command on the Pi, i get an error saying
Could not find or load main class application.Main
If i change the .jar file into a .zip, i can clearly see a directory called application, and file called Main.class
So why is my program working on my (windows 10) machine, whether i run it from eclipse or the command line, but not on the raspberry Pi?
To install the Java Runtime Environment (JRE) run the following command:
sudo apt-get install openjdk-7-jre
This installs the Java JRE (Java Runtime Environment) which will allow you to run applications written in Java.
To install the JDK run the command:
sudo apt-get install openjdk-7-jdk
This allows you to compile Java applications to bytecode.
If you want the Oracle Java VM, which is a lot faster (optimized for embedded arm CPUs) and is also a developer preview (applications maybe buggy or crash) until some time into the future. Instead of the above instructions you need to download the file called Oracle JDK 8 (with JavaFX) for ARM Early Access on the Oracle Java 8 download page.
Remember to download the Oracle Java system on your Pi, or you won't be able to install it.
To install the Oracle Java System:
sudo tar zxvf jdk-8-ea-b36e-linux-arm-hflt-*.tar.gz -C /opt
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/jdk1.8.0/bin/java" 1
sudo update-alternatives for other commands if needed (e.g. javac).
java -version
Then it is all installed.
Another thing, if you have more then one Java runtime installed you have to check which version you use with the command java -version. If the output is:
java version 1.5.0 gij (GNU libgij)
Then you are using another java runtime. You can resolve the issue by running
sudo update-alternatives --config java
and choosing the OpenJDK or Oracle option.