问题描述
我有这个java程序,我想在jar包中。
它编译良好,它无错误地编译到jar中。但是当我双击它,它不会开始。我知道大多数jar应用程序使用JFrame和工作正常。但是有可能使它命令提示符/ shell为基础吗? (像显示System.out.println)
I have this java program that I want to package within a jar.It compiles fine and it compiles without errors into a jar. But when I double click it, it wont start. I know most jar applications uses JFrame and that works fine. But is it possible to make it command prompt/shell based? (Like Displaying System.out.println)
例如,可以通过双击jar来执行这个代码:
Example is it possible to execute this code by double clicking a jar:
public class Hello
{
public static void main( String[] args )
{
System.out.println( "Hello, World!" );
}
}
推荐答案
是没有问题这样做。
如果你从控制台执行 java -jar my jar.jar
您将看到您的Hello,World。
If you execute from the console as java -jar my jar.jar
you will see your "Hello, World".
如果要双击,您需要创建一个JFrame。
If you want to double-click you'll need to create a JFrame.
这篇关于在jar中的System.out.println的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!