当前位置: 首页 > 知识库问答 >
问题:

当JAVA_HOME指向JRE时,Javafx带阴影的Jar不工作

岳杜吟
2023-03-14

我创建了一个在Java11上运行的带阴影的jar。当我没有安装除11以外的其他java版本时,一切工作都很好

但当我还安装并将java home设置为Java8时

注意:C:\jdk是java 8路径

<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>
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)

共有1个答案

符鸿光
2023-03-14

基本答案相当简单。JavaFX11+不在Java8上运行。这与你的阴影无关。

 类似资料:
  • 然后卸载OpenJDK并安装Oracle JDK8,现在运行时 JAVA_HOME环境变量定义不正确运行此程序需要此环境变量nb:JAVA_HOME应该指向JDK,而不是JRE 我正在运行Linux Mint 19,我确实遇到了一些与这个问题相关的Stackoverflow问题。大多数与Windows有关,一些与Linux有关。建议运行的Linux

  • 我下载了jdk-9.0.1_linux-x64_bin。焦油gz和jre-9.0.1_linux-x64_bin。焦油来自链接的gzhttp://www.oracle.com/technetwork/java/javase/downloads/index.html.将它们提取出来,并在/usr/local/java中发布。然后编辑/etc/profile以添加 整个文件看起来像 然后输入以下命令

  • 我已经用编辑了服务器上的文件 我已经重新登录,以下是输出的所有路径: 但是当我尝试运行我的spring boot服务器时,它给了我:

  • 我将指向。很好用。之后,解压ant并设置与ant相关的环境变量,在键入后,得到以下错误消息 我搜索了这个论坛。看起来一个解决方案是将Java指向JDK,而不是JRE。我不确定这是否应该是解决办法。换句话说,一般来说,JAVA_HOME应该指向哪一个?JDK还是JRE?

  • 问题内容: 我正在尝试遵循有关如何使用ant来构建和运行您的应用程序的教程。我遵循了所有步骤并创建了构建文件,但是当我尝试运行ant时,会出现此错误。 失败/home/bilal/tmp/ant/build.xml:19:无法找到Javac编译器;com.sun.tools.javac.Main不在类路径中。也许JAVA_HOME没有指向JDK。当前设置为“ / usr / lib / jvm /