IntelliJ工件构建不从终端运行 [英] IntelliJ artifact build not running from terminal

查看:144
本文介绍了IntelliJ工件构建不从终端运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用IntelliJ Idea社区版运行Ubuntu 16.04 LTS。

I'm running Ubuntu 16.04 LTS with IntelliJ Idea Community Edition.

完成我的桌面应用程序后,我希望导出为独立应用程序运行。我安装了JRE9。

Having finished my desktop application I wish to export to run as a standalone application. I have JRE9 installed.

按照此视频,也与IntelliJ网站教程相同。

Following the quick 60 seconds tutorial in this video, which is also the same as on the IntelliJ web site tutorial.

所以我转到项目结构,工件,添加,转到JavaFX选项卡,选择主类,确定,构建工件,打开包含文件夹和...

So I go to Project Structure, Artifacts, Add, Go to JavaFX tab, select the main class, OK, the build the artifact, open the containing folder and...

双击.jar文件说它不是可执行文件,所以我 chmod + x file.jar 使其可执行,但仍然无法运行。

Double clicking the .jar file says it's not executable, so I chmod +x file.jar to make it executable, and that still doesn't run.

所以在终端我转到目录并输入 java -jar file.jar 但是说错误:无法找到或加载主类示例.Main

So in the terminal I go to the directory and type java -jar file.jar but that says Error: Could not find or load main class sample.Main.

但是我在Artifact窗口中选择了主类。

But I've selected the main class in the Artifact window.

任何想法如何解决这个问题?谢谢。

Any ideas how to fix this? Thanks.

UPDATE

我的目录/文件/文件内容结构如下这个:

My directory/file/file contents structure looks like this:

WorkingDirectory
    Myjar.jar
        META-INF
            MANIFEST.MF
                Manifest-Version: 1.0
                Created-By: JavaFX Packager
                Main-Class: sample.Main
                Class-Path: 
                Permissions: sandbox
                JavaFX-Version: 9.0.4
        sample
            Main.class
                public static void main(String[] args) { launch(args); }
    MyLib1.jar
    MyLib2.jar

我还有 .jar files

推荐答案

多么噩梦。我的系统上似乎安装了两个JDK,我的IntelliJ项目设置为使用JDK 9.0.4。我的Linux系统默认为其他版本。

What a nightmare. It seems I have two JDK's installed on my system, and my IntelliJ project is setup to use JDK 9.0.4. My Linux system is defaulting to some other version.

所以我需要输入的最后一个是 /opt/jdk-9.0.4/ bin / java -jar JavaFXApp.jar

So all I needed to type in the end was /opt/jdk-9.0.4/bin/java -jar JavaFXApp.jar.

浪费了两天。

这篇关于IntelliJ工件构建不从终端运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆