使用Eclipse创建一个java可执行文件 [英] Create a java executable with Eclipse

查看:141
本文介绍了使用Eclipse创建一个java可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个完全新手的问题。我在Ubuntu上运行Eclipse。我创建了一个测试项目,我想编译为一个可执行文件(无论linux等价是一个Windows .exe文件)。这是我的程序的内容:

  public class MyTest {
public static void main(String [] args){

System.out.println(您传入:+ args [0]);

}
}

我想知道如何编译




解决方案

您需要创建一个可执行的JAR文件。





右键单击项目,然后在导出下选择JAR文件。 b

>



输入要保存的路径。这里的示例是Windows。根据您的平台更改





https://i.stack.imgur.com/RSJmn.pngalt =enter image description here>



通过浏览来编辑主类字段并选择包含 main 方法的类的位置。





运行 / p>

要运行JAR文件,请打开shell或命令提示符并执行以下命令:



java -jar path / to / test.jar


This is a totally newbie question. I'm running Eclipse on Ubuntu. I created a test project that I want to compile to an executable (whataver the linux equivalent is of a Windows .exe file). Here's the contents of my program:

public class MyTest {
    public static void main(String[] args) {

        System.out.println("You passed in: " + args[0]);

    }
}

I want to know how to compile it and then how to execute it from the command line.

Thanks!

解决方案

You need to create an executable JAR file. Steps will follow shortly.

Right click on the project and select JAR file under Export.

Enter the path where you want it to be saved. The example here is of Windows. Change according to your platform.

Click Next.

Edit the Main Class field by browsing and selecting the location of your class that contains the main method.

Run it

To run the JAR file, open up a shell or command prompt and execute the following command:

java -jar path/to/test.jar

这篇关于使用Eclipse创建一个java可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆