为什么用Java制作的exe文件会立即关闭?

huangapple go评论82阅读模式
英文:

Why does an exe file made with java immediately turn off?

问题

我在eclipse中制作了一个jar文件,并将其从jsmooth转换为exe文件。
exe文件已创建,但如果我双击它,它会立即关闭。
是我的代码有问题吗?

public class plz {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        System.out.println("Hello World!");
        for (int i = 0; i < args.length; i++) {
            System.out.format("args[%d]: %2 %n", i, args[i]);
        }

    }
}
英文:

I made a jar in eclipse and converted it from jsmooth to exe.
The exe is created, but if I double-click it, it turns off immediately.
Is my code the problem?

public class plz {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

        System.out.println(&quot;Hello World!&quot;);
        for(int i = 0; i&lt; args.length; i++) {
            System.out.format(&quot;args[%d}: %2 %n&quot;, i, args[i]);
        }

    }
}

答案1

得分: 1

是的,就是这样。您的代码指定应该循环遍历参数列表(在启动应用程序时提供)。一旦完成此操作,应用程序将停止。

英文:

Yes, it is.
Your code states that it should loop through the list of arguments(which you provide when you start the application). Once this is done, the application will stop.

huangapple
  • 本文由 发表于 2020年10月14日 17:29:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/64350362.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定