I have created a shaded jar which runs on java 11. Everything works fine when i have no other java version than 11 installed
But when i also install and set java home to java 8
JAVA_HOME: C:\jdk\ (Jar Working)
JAVA_HOME: C:\jdk\jre\ (Jar Not Working shows blank screen) [1]: https://i.stack.imgur.com/s28ef.jpg
Note: c:\jdk is java 8 path
Below is my pom for creating shaded jar
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>test</name>
<description>test</description>
<properties>
<!-- Generic properties -->
<java.version>11.0.7</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>GUIStarter</mainClass>
<systemProperties>
<systemProperty>
<key>prism.allowhidpi</key>
<value>false</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.1.3-SNAPSHOT</version>
<configuration>
<mainClass>GUIStarter</mainClass>
<bundler>EXE</bundler>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.3</version>
<configuration>
<options>
<option>--add-opens</option>
<option>javafx.graphics/javafx.css=ALL-UNNAMED</option>
<option>--add-opens</option>
<option>javafx.base/com.sun.javafx.runtime=ALL-UNNAMED</option>
<option>--add-opens</option>
<option>javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED</option>
<option>--add-opens</option>
<option>javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED</option>
<option>--add-opens</option>
<option>javafx.base/com.sun.javafx.binding=ALL-UNNAMED</option>
<option>--add-opens</option>
<option>javafx.base/com.sun.javafx.event=ALL-UNNAMED</option>
<option>--add-opens</option>
<option>javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED</option>
<option>--add-exports</option>
<option>javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix</option>
<option>--add-exports</option>
<option>javafx.controls/com.sun.javafx.scene.control=com.jfoenix</option>
<option>--add-exports</option>
<option>javafx.base/com.sun.javafx.binding=com.jfoenix</option>
<option>--add-exports</option>
<option>javafx.graphics/com.sun.javafx.stage=com.jfoenix</option>
<option>--add-exports</option>
<option>javafx.base/com.sun.javafx.event=com.jfoenix</option>
</options>
<mainClass>GUIStarter</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<options>
<option>--add-opens</option>
<option>javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix
</option>
<option>--add-opens</option>
<option>javafx.controls/com.sun.javafx.scene.control=com.jfoenix
</option>
</options>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Multi-Release>true</Multi-Release>
<Main-Class>GUIStarter</Main-Class>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
I Tried executing Jar from Command Prompt getting below exception on startup
java.lang.NullPointerException
at com.sun.javafx.font.directwrite.DWGlyph.createBitmap(DWGlyph.java:287)
at com.sun.javafx.font.directwrite.DWGlyph.getCachedBitmap(DWGlyph.java:273)
at com.sun.javafx.font.directwrite.DWGlyph.getD2DMask(DWGlyph.java:167)
at com.sun.javafx.font.directwrite.DWGlyph.getPixelData(DWGlyph.java:352)
at com.sun.prism.impl.GlyphCache.getCachedGlyph(GlyphCache.java:258)
at com.sun.prism.impl.GlyphCache.render(GlyphCache.java:148)
at com.sun.prism.impl.ps.BaseShaderGraphics.drawString(BaseShaderGraphics.java:2101)
at com.sun.javafx.sg.prism.NGText.renderText(NGText.java:312)
at com.sun.javafx.sg.prism.NGText.renderContent2D(NGText.java:270)
at com.sun.javafx.sg.prism.NGShape.renderContent(NGShape.java:261)
at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
at com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:479)
at com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:328)
at com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:91)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
at com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
at java.base/java.lang.Thread.run(Thread.java:834)