在 Android Studio 中运行 Java 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27765834/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 12:21:25  来源:igfitidea点击:

Running Java application in Android Studio

javaandroidandroid-studiolibgdx

提问by nikoliazekter

I created new libgdx project and i want to run desktop application in Android Studio. Is there something to do with run configurations? In Eclipse i can just choose Run as Java Application.

我创建了新的 libgdx 项目,我想在 Android Studio 中运行桌面应用程序。与运行配置有关吗?在 Eclipse 中,我可以选择 Run as Java Application。

回答by nikoliazekter

Ok, i did it. Here is the solution https://github.com/libgdx/libgdx/wiki/Gradle-and-Intellij-IDEA#running-your-project

好的,我做到了。这是解决方案https://github.com/libgdx/libgdx/wiki/Gradle-and-Intellij-IDEA#running-your-project

Run -> Edit Configurations..., click the plus (+) button and select Application.

Run -> Edit Configurations...,单击加号 ( +) 按钮并选择应用程序。

Set the Name to Desktop.

将名称设置为Desktop

Set the field Use classpath of moduleto desktop, then click on the button of the Main classfield and select the DesktopLauncherclass.

将字段设置Use classpath of moduledesktop,然后单击字段的按钮Main class并选择DesktopLauncher类。

Set the Working directoryto your android/assets/(or your_project_path/core/assets/) folder!

将 设置Working directory为您的android/assets/(或your_project_path/core/assets/)文件夹!

Click Applyand then OK.

单击Apply,然后单击OK

You have now created a run configuration for your desktop project. You can now select the configuration and run it.

您现在已经为您的桌面项目创建了一个运行配置。您现在可以选择配置并运行它。

回答by JBaruch

Right click on the main method (or anywhere in the main class) and select Run.

右键单击主方法(或主类中的任何位置)并选择运行。