简体   繁体   English

从另一个Java应用程序运行桌面应用程序

[英]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.

相关问题 如何从正在运行的项目中(特别是在NetBeans中)以及在桌面应用程序的情况下运行另一个Java项目? - How to run another Java project from a running project specially in NetBeans and in case of a desktop application? 从 Java 桌面应用程序为 Android 应用程序运行 Gradle 构建脚本 - Running Gradle Build Script from Java Desktop Application for Android App Java桌面应用程序未从可执行jar文件运行 - java desktop application not running from executable jar file 从另一个正在运行的Java应用程序中捕获异常 - Catching an exception from another running Java application 将数据从Blackberry应用程序发送到另一个正在运行的应用程序(而不是正在运行的应用程序)? - send data from Blackberry application to another running application(and not running application)? 来自Java桌面应用程序的Web视图 - Web view from java desktop application 参考 java 中桌面应用程序的文档 - Refer a Document from a desktop application in java 将数据从android传输到Java桌面应用程序 - Transfer data from android to java desktop application 从桌面应用程序使用Java发布表单 - Post form with Java from desktop application 将文件从桌面上传到Java Applet应用程序 - Upload file from desktop to Java applet application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM