Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Intellij idea 运行Java11.02JavaFX.jar应用程序会产生奇怪的输出_Intellij Idea_Javafx_Jar_Java 11 - Fatal编程技术网

Intellij idea 运行Java11.02JavaFX.jar应用程序会产生奇怪的输出

Intellij idea 运行Java11.02JavaFX.jar应用程序会产生奇怪的输出,intellij-idea,javafx,jar,java-11,Intellij Idea,Javafx,Jar,Java 11,我一直在尝试创建并运行一个.jar文件,我可以在任何运行Java运行时环境的计算机上运行我的JavaFX应用程序 对于Java,我运行的是sdk版本11.02,对于JavaFX,我运行的是11.02 jdk。我的IDE是IntellJ的想法。我已确保Windows环境变量设置正确,如下所示: JAVA_HOME: C:\Program Files\Java\jdk-11.0.2 在路径系统变量中: c:\program files\java\jdk-11.0.2\bin c:\program

我一直在尝试创建并运行一个.jar文件,我可以在任何运行Java运行时环境的计算机上运行我的JavaFX应用程序

对于Java,我运行的是sdk版本11.02,对于JavaFX,我运行的是11.02 jdk。我的IDE是IntellJ的想法。我已确保Windows环境变量设置正确,如下所示:

JAVA_HOME: C:\Program Files\Java\jdk-11.0.2
在路径系统变量中:

c:\program files\java\jdk-11.0.2\bin
c:\program files\javafx-sdk-11.0.2\lib
在Intellj IDEA中,我确保路径变量的设置如下:

我还确保我的项目使用了正确的Java版本,并且使用了javafx库:

我还确保Application runner中的VM选项具有正确的命令:

有了它,我可以通过IDE内置的应用程序运行器毫无问题地运行JavaFX程序。但如果我尝试创建一个jar文件并运行它,情况就不是这样了。我试着按照第一个答案的指南去做,也就是他谈到一个胖罐子的那部分

我按照他的建议创建了一个Launcher类,与我的唯一区别是我需要添加一个throw exception子句,否则我在.main部分遇到了一个未处理的异常错误

package main;

import com.sun.tools.javac.Main;

public class Launcher {
    public static void main(String[] args) throws Exception {
        Main.main(args);
    }
}
这是我最初的JavaFX入口点:

public class Main extends Application
{
    private ArmyBuilderRootPane view;

    @Override
    public void init()
    {
        Army model = new Army();
        view =  new ArmyBuilderRootPane(); 
        new ArmyBuilderController(view, model);     
    }

    @Override
    public void start(Stage stage)
    {
        stage.setTitle("Space Marine Army Builder");
        stage.setScene(new Scene(view));
        stage.show();
    }

    public static void main(String[] args)
    {
        launch(args);
    }
}
然后,我按照他创建.jar文件的方式,首先在项目结构中设置工件,然后最终构建它。当我尝试在内部IDE中运行此.jar并在外部Windows命令行中使用命令:
java-jar-SpaceMarineArmyBuilder.jar
时:我得到以下输出:

"C:\Program Files\Java\jdk-11.0.2\bin\java.exe" --module-path "C:/Program Files/javafx-sdk-11.0.2/lib" --add-modules javafx.controls,javafx.fxml -Dfile.encoding=windows-1252 -jar "D:\Projects\Code\Space Marine Army Builder (7th Edition)\classes\artifacts\SpaceMarineArmyBuilder_jar\SpaceMarineArmyBuilder.jar"
Usage: javac <options> <source files>
where possible options include:
  @<filename>                  Read options and filenames from file
  -Akey[=value]                Options to pass to annotation processors
  --add-modules <module>(,<module>)*
        Root modules to resolve in addition to the initial modules, or all modules
        on the module path if <module> is ALL-MODULE-PATH.
  --boot-class-path <path>, -bootclasspath <path>
        Override location of bootstrap class files
  --class-path <path>, -classpath <path>, -cp <path>
        Specify where to find user class files and annotation processors
  -d <directory>               Specify where to place generated class files
  -deprecation
        Output source locations where deprecated APIs are used
  --enable-preview
        Enable preview language features. To be used in conjunction with either -source or --release.
  -encoding <encoding>         Specify character encoding used by source files
  -endorseddirs <dirs>         Override location of endorsed standards path
  -extdirs <dirs>              Override location of installed extensions
  -g                           Generate all debugging info
  -g:{lines,vars,source}       Generate only some debugging info
  -g:none                      Generate no debugging info
  -h <directory>
        Specify where to place generated native header files
  --help, -help, -?            Print this help message
  --help-extra, -X             Print help on extra options
  -implicit:{none,class}
        Specify whether or not to generate class files for implicitly referenced files
  -J<flag>                     Pass <flag> directly to the runtime system
  --limit-modules <module>(,<module>)*
        Limit the universe of observable modules
  --module <module-name>, -m <module-name>
        Compile only the specified module, check timestamps
  --module-path <path>, -p <path>
        Specify where to find application modules
  --module-source-path <module-source-path>
        Specify where to find input source files for multiple modules
  --module-version <version>
        Specify version of modules that are being compiled
  -nowarn                      Generate no warnings
  -parameters
        Generate metadata for reflection on method parameters
  -proc:{none,only}
        Control whether annotation processing and/or compilation is done.
  -processor <class1>[,<class2>,<class3>...]
        Names of the annotation processors to run; bypasses default discovery process
  --processor-module-path <path>
        Specify a module path where to find annotation processors
  --processor-path <path>, -processorpath <path>
        Specify where to find annotation processors
  -profile <profile>
        Check that API used is available in the specified profile
  --release <release>
        Compile for a specific VM version. Supported targets: 6, 7, 8, 9, 10, 11
  -s <directory>               Specify where to place generated source files
  -source <release>
        Provide source compatibility with specified release
  --source-path <path>, -sourcepath <path>
        Specify where to find input source files
  --system <jdk>|none          Override location of system modules
  -target <release>            Generate class files for specific VM version
  --upgrade-module-path <path>
        Override location of upgradeable modules
  -verbose                     Output messages about what the compiler is doing
  --version, -version          Version information
  -Werror                      Terminate compilation if warnings occur


Process finished with exit code 2
“C:\Program Files\Java\jdk-11.0.2\bin\Java.exe”--模块路径“C:/Program Files/javafx-sdk-11.0.2/lib”--添加模块javafx.controls,javafx.fxml-Dfile.encoding=windows-1252-jar“D:\Projects\code\Space Marine Army Builder(第七版)\classes\artifacts\SpaceMarineArmyBuilder\u jar\SpaceMarineArmyBuilder.jar”
用法:javac
可能的选择包括:
@从文件中读取选项和文件名
-要传递给注释处理器的Akey[=value]选项
--添加模块(,)*
除初始模块或所有模块外,还要解析根模块
在模块路径上,如果为ALL-module-path。
--引导类路径,-bootclasspath
重写引导类文件的位置
--类路径,-classpath,-cp
指定查找用户类文件和注释处理器的位置
-d指定放置生成的类文件的位置
-贬低
使用不推荐的API的输出源位置
--启用预览
启用预览语言功能。与-source或-release一起使用。
-编码指定源文件使用的字符编码
-ENDORSEDIR覆盖已认可标准路径的位置
-extdirs覆盖已安装扩展的位置
-g生成所有调试信息
-g:{lines,vars,source}只生成一些调试信息
-g:无生成调试信息
-h
指定放置生成的本机头文件的位置
--救命啊,救命啊?打印此帮助消息
--附加帮助,-X打印附加选项的帮助
-隐式:{none,class}
指定是否为隐式引用的文件生成类文件
-J直接传递到运行时系统
--极限模(,)*
限制可观测模块的范围
--模,-m
只编译指定的模块,检查时间戳
--模块路径,-p
指定查找应用程序模块的位置
--模块源路径
指定在何处查找多个模块的输入源文件
--模块版本
指定正在编译的模块的版本
-nowarn不生成警告
-参数
生成元数据以反映方法参数
-proc:{none,only}
控制是否完成注释处理和/或编译。
-处理器[,…]
要运行的注释处理器的名称;绕过默认的发现过程
--处理器模块路径
指定用于查找注释处理器的模块路径
--处理器路径,-processorpath
指定在何处查找批注处理器
-侧面图
检查所使用的API是否在指定的配置文件中可用
--释放
为特定VM版本编译。支持的目标:6、7、8、9、10、11
-s指定放置生成的源文件的位置
-来源
提供与指定版本的源代码兼容性
--源路径,-sourcepath
指定查找输入源文件的位置
--系统|无覆盖系统模块的位置
-目标生成特定VM版本的类文件
--升级模块路径
覆盖可升级模块的位置
-详细输出有关编译器正在执行的操作的消息
--版本-版本信息
-如果出现警告,Werror将终止编译
进程已完成,退出代码为2
我不知道它为什么会产生这种输出。它应该运行我的JavaFX应用程序

如果有人能帮助我,我将不胜感激


谢谢

您确定运行的是
java
而不是
javac
?可能是JDK损坏,请尝试重新安装。@CrazyCoder好吧,我确信我在外部Windows CMD中运行时会编写java-jar SpaceMarineArmyBuilder.jar作为命令。您是想重新安装JavaJDK还是JavaFX?如果是这样的话,在这两个版本上升级到13版是否值得?谢谢