[英]running a desktop application from another java application
With the help of Netbeans, I made a Java desktop application. 在Netbeans的帮助下,我制作了一个Java桌面应用程序。 I just made another class in that package where I just added a button. 我刚刚在该程序包中添加了另一个类,在其中添加了一个按钮。 I meant it for the purpose of running Java desktop application which I made earlier. 我的意思是为了运行我之前制作的Java桌面应用程序。 When searched for the main method of appview.java (only this contains a main) there was code like this: 当搜索appview.java的主要方法(仅包含main)时,代码如下:
public static void main(String[] args) {
launch(SRECOApp.class, args);
}
I tried to put launch(SRECOApp.class, args);
我试图把launch(SRECOApp.class, args);
in the action listener of the button, but it didn't work. 在按钮的动作侦听器中,但没有成功。 Please, what should I do now? 拜托,我现在该怎么办?
This is what the Desktop class and the Runtime class are meant for. 这就是Desktop类和Runtime类的目的。
Desktop class is more to open an application associated to a file (via its file extension). 桌面类更多的是打开与文件关联的应用程序(通过文件扩展名)。
Runtime class is more to open an application and passing parameters to this application. 运行时类更多的是打开应用程序并将参数传递给该应用程序。
Eg: 例如:
Runtime.getRuntime().exec("notepad.exe")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.