[英]NetBeans made jar file won't launch by double clicking
I know this problem has been discussed many times here. 我知道这个问题已经在这里讨论了很多次。 I am running on MAC with OSX 10.7.4 and NetBeans 7.2.1
我在OSX 10.7.4和NetBeans 7.2.1的MAC上运行
I don't know if this is a new wrinkle or not, I'm a java newbie. 我不知道这是不是新皱纹,我是Java新手。 In any event with my project selected in the projects window it shows the project:
无论如何,只要在项目窗口中选择了我的项目,它就会显示该项目:
Idealizer -> Source Packages -> components-> AlsRun.java, GraphingData.java, Idealizer.java, jButtonListenerExample.java
. Idealizer -> Source Packages -> components-> AlsRun.java, GraphingData.java, Idealizer.java, jButtonListenerExample.java
。
AlsRun is the main class. AlsRun是主要的类。 I can run the code from within the IDE or by zipping up dist and moving it anywhere and typing:
java -jar "Idealizer.jar
" (from within "dist"). 我可以从IDE内运行代码,也可以通过压缩dist并将其移动到任何地方并键入以下代码来运行代码:
java -jar "Idealizer.jar
”(从“ dist”内部)。
On the other discussions of this problem it seemed that MANIFEST.MF was implicated. 关于此问题的其他讨论似乎与MANIFEST.MF有关。 MANIFEST.MF appears correct:
MANIFEST.MF似乎正确:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.3
Created-By: 1.6.0_35-b10-428-11M3811 (Apple Inc.)
Class-Path:
X-COMMENT: Main-Class will be added automatically by build
Main-Class: components.AlsRun
I believe that the following are two big hints. 我相信以下是两个重要提示。
Big Hint 1 : 大提示1 :
When I run the code from the command line the program takes over and the program name that appears on the screen is "components.AlsRun" . 当我从命令行运行代码时,程序将接管程序,并且屏幕上显示的程序名称为“ components.AlsRun”。 When I attempt to launch it by double clicking (from the finder) a program is launched and the name that appears is "AlsRun".
当我尝试通过双击(从查找器)启动它时,将启动一个程序,出现的名称为“ AlsRun”。 The program that is launched in the latter case does nothing and I can only kill it from within "force quit".
在后一种情况下启动的程序没有任何作用,我只能在“强制退出”范围内将其杀死。
Big Hint 2 : 大提示2 :
After writing the last sentence I asked myself how to kill it from the command line. 写完最后一句话后,我问自己如何从命令行中删除它。 If I ran the program by double clicking and then ran
ps -A | grep java
如果我双击运行程序,然后运行
ps -A | grep java
ps -A | grep java
it returned the following: ps -A | grep java
它返回以下内容:
33383 ?? 0:00.84 /Library/Internet Plug-ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
- jar /Users/pearson/NetBeansProjects/Idealizer/dist/Idealizer.jar -jar /用户/皮尔逊/NetBeansProjects/Idealizer/dist/Idealizer.jar
When I run the program from the command line and then do ps -A | grep java
当我从命令行运行程序,然后执行
ps -A | grep java
ps -A | grep java
it returns ps -A | grep java
它返回
33394 ttys001 0:01.46 /usr/bin/java -jar Idealizer.jar
It runs different versions of java depending on if I launch it by double clicking or the command line. 它运行不同版本的Java,具体取决于我是通过双击还是通过命令行启动它。
Apparently NetBeans thinks I am creating an "Applet" which is different than an Application? 显然NetBeans认为我正在创建一个与Application不同的“ Applet”?
I am at a loss here. 我在这里茫然。 The shortest version of the code that produces the error for me is:
产生错误的最短代码版本是:
package components;
import javax.swing.JFileChooser;
public class AlsRun {
public static void main(String[] args) {
JFileChooser fc = new JFileChooser();
int returnVal = fc.showOpenDialog(null);
};
}
Following the instructions here: http://www.oracle.com/technetwork/articles/javase/javatomac3-137430.html 请按照此处的说明进行操作: http : //www.oracle.com/technetwork/articles/javase/javatomac3-137430.html
fixed the problem. 解决了问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.