macOS: how to install JavaFX properly to run mqtt-spy? - macos

I'm trying to run mqtt-spy-1.0.0.jar on my macOS 10.14 system but it won't start, returning the following error message:
According to the developers, this problem is caused if JavaFX is missing on the system.
The latest version of the Oracle JDK is installed on my system as can be seen below, however, I'm aware that Oracle has excluded JavaFX from the JDK in v11.
So I downloaded JavaFX from GluonHQ and followed their instructions on how to get started.
Despite having both required variables set correctly in ~/.bash_profile, mqtt-spy-1.0.0.jar is still returning the error message shown on the first screenshot ...
What else do I need to do or what do I need to do differently to run mqtt-spy?

There is already an issue filed about this, but not a solution.
I haven't really tried to get it fully working, but these are the required steps to run a jar on Java 11 that requires JavaFX 11, but doesn't bundle it:
Go to OpenJFX docs and read about how to get started with JavaFX 11.
Download JavaFX 11 for your platform from here. Unzip it
Providing that you have Java 11 installed, and set as JAVA_HOME:
With mqtt-spy-1.0.0.jar (as latest release), you can run:
java --module-path /path-to/javafx-sdk-11.0.1/lib \
--add-modules javafx.controls,javafx.fxml -jar mqtt-spy-1.0.0.jar
After you run this, you will get this exception:
Exception in Application start method
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
Since Java 9, JAXB is not part of the JDK either. So you can add try to download the dependency from here) and add it to the classpath. But this will take some iterations (there are a few other required jars more, see this).
So why don't you use the latest snapshot available, that includes dependencies: mqtt-spy-1.0.1-beta-b18-jar-with-dependencies.jar.
With this:
java --module-path /path-to/javafx-sdk-11.0.1/lib \
--add-modules javafx.controls,javafx.fxml -jar mqtt-spy-1.0.1-beta-b18-jar-with-dependencies.jar
I get:
Warning: But this doesn't mean that the app will fully work. Given that it is a Java 8 app, there are things that have changed in JavaFX 11, mainly related to the control skins. If the app was using private API (com.sun.javafx....), that won't work now, because either it has been moved to public packages, or because it is not accessible by the modules. For the latter you can use --add-opens, but for the former there is no solution other than update the app dependencies to Java 9+.

Related

Sync error while trying to build project in IntelliJ

Getting the following sync error while trying to build my first helloWorld program in IntelliJ.
I've installed IntelliJ for the first time on my computer running Windows 10.
Could not open init generic class cache for initialization script 'C:\Users\nikhils\AppData\Local\Temp\wrapper_init5.gradle' (C:\Users\nikhils\.gradle\caches\6.6.1\scripts\2xaig2b083uxqwleg0fdntova).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 60
Change project and Gradle JDK to the supported version (8—15). Current Gradle release versions do not support Java 16. You would need Gradle 7 if you want to use Java 16.
The easiest way would be to create a new project with Java 11.
Also note that full Java 16 support will be available starting from IntelliJ IDEA 2021.1 release (current release version is 2020.3.3).
See https://www.jetbrains.com/idea/nextversion/ if you want to give it a try.

Unable to start Spring Boot executable jar using IBM JRE 1.8

We have a Spring Boot application which is built as an executable jar and runs fine using both the Oracle and OpenJDK JREs (using 1.8 versions).
Attempting to run it using the IBM 1.8 JRE however results in the following error at the command line.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
This occurs if we execute the jar (using ./application.jar) or using java -jar application.jar
This led us to change the packaging to not make the jar executable and this allows us to start the application using java -jar application.jar. So it appears the IBM JRE doesn't like the launch script.
The problem is we don't want to have two packaging methods for different deployment environments, if possible.
Does anyone have any experience of why the IBM JRE doesn't like the script on the front of the jar file and whether there are any command line options to disable whatever checking its doing?
From your post it is unclear if you have problem with
1) running jar from Linux like chmod a+x application.jar and executing
Or
2) running via /opt/IBM/java/jre/bin/java -jar application.jar
For option 1) it is not a good idea as you do not explicitly choose jvm binary and rely on OS to choose one for you.
Read about binfmt_misc mechanism:
https://en.m.wikipedia.org/wiki/Binfmt_misc
For option 2)-it might be class loading problem, please add
/opt/IBM/java/jre/bin/java -verbose:class -jar application.jar
and consult documentation here: https://www.ibm.com/developerworks/library/j-dclp1/index.html

Unable to execute a JavaFX application bundled without JRE

I'm having some troubles trying to deploy a JavaFX application. In order to simplify my problem I've tried to do the same with a "Hello word" application and the problem is the same.
I'm currently using IntelliJ IDEA and Gradle.
My build.gradle file is this:
apply plugin: 'java'
apply from: "http://dl.bintray.com/content/shemnon/javafx-gradle/8.1.1/javafx.plugin"
repositories {
mavenCentral()
}
javafx {
mainClass 'Main'
}
That build.gradle file works. The problem is that it embeds the JRE into the bundle so the file size is about 175 MB. That's too much for a simple "Hello World" app, don't you think?
So, I want to bundle this simple app without the JRE (yes, I know that I should distribute my app with the JRE bundled so it doesn't relay on uses system but I'm going to distribute both versions: with and without JRE bundled). In order to do this I add a single line to the build.gradle file (as explained in this link:
...
javafx {
mainClass 'Main'
javaRuntime '<NO RUNTIME>'
}
But no bundles are generated when gradle jfxDeploy. In fact, running gradle jfxDeploy -i show some interesting info:
Java runtime to be bundled: none, bundle will rely on locally installed runtimes
...
Skipping Mac Application Image because of configuration error The file for the Runtime/JRE directory does not exist.
Advice to Fix: Point the runtime parameter to a directory that containes the JRE.
Skipping DMG Installer because of configuration error The file for the Runtime/JRE directory does not exist.
Advice to Fix: Point the runtime parameter to a directory that containes the JRE.
Skipping PKG Installer because of configuration error The file for the Runtime/JRE directory does not exist.
Advice to Fix: Point the runtime parameter to a directory that containes the JRE.
Skipping Mac App Store Ready Bundler because of configuration error The file for the Runtime/JRE directory does not exist.
Advice to Fix: Point the runtime parameter to a directory that containes the JRE.
Ok, so maybe the plugin has some bugs. I try to generate the bundle with javapackager. I go to project folder and run the following:
javapackager -deploy -native image -srcfiles build/libs/ -outdir build/distributions -outfile Sample -appclass Main
The output is OK. The bundle is correctly generated with the JRE embedded. Now I try to generate a bundle without the JRE with this:
javapackager -deploy -native image -srcfiles build/libs/ -outdir build/distributions -outfile Sample -appclass Main -Bruntime=
(It's the same command appending -Bruntime= as explained in this link).
The bundle is generated. Now its size is about 500 KB. But when I try to run it nothing happens. Running it in a terminal gives the following (simplified) output:
$ Main.app/Contents/MacOS/Main
Failed to find library.:
Main:Failed to locate JNI_CreateJavaVM
Main:Failed to launch JVM
It seems that the bundle is not capable to start the local JVM. The jar is correctly generated and added to the bundle. Running it with java -jar runs the app but I don't know why it doesn't work when running the bundle
FYI, I'm running java 1.8.0_74, javac 1.8.0_74 and javapackager 8.0 in an OS X 10.11.2
The javafx.plugin from shemnon isn't developed nor maintained anymore, for that reason I've created the javafx-gradle-plugin.
The problem comes with the internal changes of the .cfg-file-format, they use INI-files now, but that is flawed in term of RUNTIME-configuration.
Official JDK-bug-tickets reported by me:
(jdk 9) https://bugs.openjdk.java.net/browse/JDK-8143314
(jdk 8) https://bugs.openjdk.java.net/browse/JDK-8143934
It should be enough to set some bundler-argument launcher-cfg-format to cfg within your build (or use the javafx-gradle-plugin, which includes that workaround automatically).
Disclaimer: I'm the maintainer of the javafx-maven-plugin and the creator and maintainer of the javafx-gradle-plugin.
UPDATE this got fixed and made available with JDK 8u92

FHIR build fails with NoSuchMethodError: net.sf.saxon.Configuration.newConfiguration()

Following instructions at http://wiki.hl7.org/index.php?title=FHIR_Build_Process my FHIR build is failing. I modified the publish.bat to ensure it uses the correct JDK. Running it on Windows 7 64-bit machine with JDK 1.6 (also tried JDK 1.7) and both failing with same error.
Looks like some Saxon JAR hell somewhere. Any ideas?
...validate v2-tables 441sec 755MB
...validate v3-codesystems 443sec 889MB
Reference Platform Validation. 447sec 1067MB
...test adversereaction-example 447sec 1067MB
Exception in thread "main" java.lang.NoSuchMethodError: net.sf.saxon.Configuration.newConfiguration()Lnet/sf/saxon/Configuration
;
at net.sf.saxon.xpath.XPathFactoryImpl.<init>(XPathFactoryImpl.java:33)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at javax.xml.xpath.XPathFactoryFinder.loadFromService(XPathFactoryFinder.java:401)
at javax.xml.xpath.XPathFactoryFinder._newFactory(XPathFactoryFinder.java:222)
at javax.xml.xpath.XPathFactoryFinder.newFactory(XPathFactoryFinder.java:143)
at javax.xml.xpath.XPathFactory.newInstance(XPathFactory.java:185)
at javax.xml.xpath.XPathFactory.newInstance(XPathFactory.java:99)
at org.hl7.fhir.tools.publisher.Publisher.testSearchParameters(Publisher.java:2796)
at org.hl7.fhir.tools.publisher.Publisher.testSearchParameters(Publisher.java:2785)
at org.hl7.fhir.tools.publisher.Publisher.validateRoundTrip(Publisher.java:2759)
at org.hl7.fhir.tools.publisher.Publisher.validateXml(Publisher.java:2656)
at org.hl7.fhir.tools.publisher.Publisher.execute(Publisher.java:378)
at org.hl7.fhir.tools.publisher.Publisher.main(Publisher.java:281)
A workaround... do a fresh build of the publisher tool jar from source.
Following instructions in the build/buildhowto.txt I was able to build the tool jar inside Eclipse, run the Publisher successfully from inside Eclipse and then export it as a fresh tool jar overwriting the one I pulled from SVN. The freshly build one then ran to completion from the command line.
Could be there's just a problem with the version of tools jar out there in SVN at the moment.
For the record I am working with Version 0.12-1953.
You have two classes net.sf.saxon.Configuration in your classpath. One containing the method newConfiguration() and one not.
The method is probably called from Saxon-HE 9.x, and the class net.sf.saxon.Configuration is found in saxon 8.x, while the class should have been found inside Saxon-HE 9.x, where it also is, and does have this method.
So, check your dependencies to see if saxon 8.x is called, and try replacing that with Saxon-HE 9.x, then your problem is solved

"PWC6345: There is an error in invoking javac." error when using Jetty WTP plugin to deploy a JSP page on Jetty

I'm trying to deploy a JSP-page on Jetty, using the Jetty WTP plugin for Eclipse. But I get the error below. It looks like Jetty can't find javac. Is there any settings I have to do for the Jetty WTP plugin in Eclipse or how do I fix this?
The JSP page works fine if I export my project as a .war-file to jetty\webapps and then start Jetty manually using java -jar start.jar. But it doesn't work if I deploy using the Jetty WTP plugin for Eclipse as described.
I have my JAVA_HOME set to C:\Program Files (x86)\Java\jdk1.7.0_01 and I use Jetty 8.0.4 on Windows 7.
Servlets is working fine with the current setup. Any suggestions on how to solve this for JSP pages?
HTTP ERROR 500
Problem accessing /MyJavaWeb/formProcess. Reason:
PWC6345: There is an error in invoking javac. A full JDK (not just JRE) is required
Caused by:
org.apache.jasper.JasperException: PWC6345: There is an error in invoking javac. A full JDK (not just JRE) is required
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:92)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:378)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:119)
at org.apache.jasper.compiler.Jsr199JavaCompiler.compile(Jsr199JavaCompiler.java:208)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:384)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:453)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:625)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:558)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:488)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:520)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:973)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:417)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:907)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:271)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:98)
at com.example.FormProcessServlet.doPost(FormProcessServlet.java:39)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:558)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:488)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:483)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:973)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:417)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:907)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
at org.eclipse.jetty.server.Server.handle(Server.java:346)
at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:442)
at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:941)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:801)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:224)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
at java.lang.Thread.run(Unknown Source)
As Jan Bartel suggested, from Jetty: How to configure JSP:
by adding the line below in the start.ini-file in Eclipse, it works fine.
-Dorg.apache.jasper.compiler.disablejsr199=true
I too happened to suddenly get the org.apache.jasper.JasperException: PWC6345 with my Eclipse installation and the Jetty Maven Plugin (which I use to start up Jetty from within Eclipse).
The reason was that I updated my JDK installation shortly before. Inside Eclipse, this caused to change the "Installed JRE" to point to a plain JRE installation instead of a full-fledged JDK installation. A JDK installation is needed for Jasper, as Jasper needs javac (which is not provided by JRE).
In my case, the solution was to provide Eclipse with the JDK installation. To do so, select Window -> Preferences -> Java -> Installed JREs. Here, click Add..., then point to your JDK installation (in my case, JRE home should point to C:\Program Files (x86)\Java\jdk1.7.0_17). Click Finish. Then back in the Installed JREs overview, remove the old JRE reference and select the newly added JDK installation.
I got the PWC6345 error when running a webapp with Run-Jetty-Run plugin.
The fix was to change the Execution environments settings in Preferences.
Since I'm using java 7 I needed to change the setting for JavaSE-1.7.
Probably other execution environments will behave similarly.
Window -> Preferences -> Java -> Installed JREs -> Execution environments
Select JavaSE-1.7 on the left -> pick the *jdk*1.7.x_xx on the right hand side
Ok, solved this after a lot of searching around.
Download any jdk and point JAVA_HOME to this jdk.
Inside this jdk folder you will find ./bin and ./jre/bin
Copy the javac from ./bin and paste it in ./jre/bin [remember copy not cut]
Now in eclipse, Run->External-Tools->External-Tools-Configurations, select the build.xml for of your project in the left pane and click on the JRE tab in the right pane.
Click on installed JREs and add the jdk in the previous step.
Once done, select this new JRE (jdk1.6.0_31) as the 'Separate JRE', click on apply at the bottom and run.
This assumes you are doing a jetty:run using ant on eclipse.
Strange because this thread suggests:
The solution was to install the package jdk7-openjdk.
Perhaps this should be added to the list of dependencies (or maybe for jetty, and not solr itself)?
But that doesn't help much on Windows, where the binary for openjdk7 aren't easily available.
(In "OpenJDK availability for Windows OS" comments, eckes mentions having found some openjdk binaries for Windows, as part of the Build b146. However, said releases aren't maintained any more)
The bug report filled by the OP Jonas is closed with a simple reference to the Eclipse wiki page "Jetty/Howto/Configure JSP".
You have planty solutions guys but I thought that it exist a solution better than fix the start.ini
I lived the same problem and then I realize that it may be because I did have a JDK7 for 64bit while I should have a JDK7 for 32.
So I fixed my problem by downloading and use the JDK7 for 32Bit.
Also, you would still need to
Use the JDK and not the JRE
Set your JAVA_HOME
I am running on Windows by the way ...
I have the same problem. When I run where java, the output is:
C:\Windows\System32\java.exe
D:\Program Files\Java\jdk1.7.0_25\bin\java.exe
Of course the first one is incorrect. So my problem lies in the PATH. I can rectify this by either removing the java.exe in the directory C:\Windows\System32\ because I'm sure it's useless, or putting the second entry in front of the first one.
So When encountering this problem, please check your PATH for the jdk. I hope that my problem and my solution is helpful in some way.
I got the PWC6345 error when running jetty-runner 9.2.1 standalone from Windows 7 cmd (or batch file) with Oracle JDK 1.7.0_60, and none of the other suggestions in this or other forums worked. I'll leave my workaround here, in case it helps someone...
After installing the JDK, running 'where java' showed two different java.exe paths, the first being in the Windows system folder, and the second in the JDK folder (which is the one I added to the path manually). Both of these are actually installed by the same JDK installer. The java.exe in the system folder was taking precedence and causing the full JDK to go undetected.
Placing the JDK bin folder (e.g. "C:\Program Files\java\jdk1.7.0_60\bin") on the path before the other system paths fixed the issue.
In addition to updating the JAVA_HOME (see above)...
If you're encountering this error from command line (e.g. starting Jetty server from dos window), check where windows is finding the java.exe:
where java
If windows comes back with a path showing to your jre, then check your PATH. Chances are the %PATH% contains a path pointing to the jre instead of jdk.
if you set environment variable JRE_HOME , please unset or delete it
and start server again .
In liferay 7 : I got this error fixed by changing the runtime environment of the server from jre to jre with jdk
I got this error when deploy war package to our server.
My deploy command is (applied web container you may find):
java -jar jetty-runner.jar --port 8020 xx.war
I write this answer because it confused me almost one day. I tried some methods above but failed.
Finally I found there is only jre on my servers but not full jdk.
$ls /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-2.b11.el7_3.x86_64
jre
I fix it with searching available jdk and install one.
$yum search java | grep 'java-'
$sudo yum install java-1.8.0-openjdk-devel.x86_64
(Notice the -devel)
I added this line to 'eclipse.ini' file which is present inside eclipse folder.
-vm
C:\Program Files\Java\jdk1.8.0_131\bin\javaw.exe
and I also change the JRE path in eclipse
windows -> preferences -> java -> Installed JREs
and provided path upto jdk
C:\Program Files\Java\jdk1.8.0_131
I spent good amount of time on this issue, but it turned out to be very simple. All you have to do is:
choose the JDK instead of JRE while configuring the server runtime!
It worked like a champ, I had this issue with glassFish 4.0

Resources