Eclipse:手动选择可执行jar文件的main类 [英] Eclipse : manually select main class for executable jar file

查看:153
本文介绍了Eclipse:手动选择可执行jar文件的main类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有java项目,很多类有main方法(仅用于测试目的)。当我通过Eclipse创建可执行的jar文件时,Eclipse会自动选择哪个文件是主类。 (并且经常出错)。



另一种方法是在Jar文件中的清单文件中更改主类。但是,它非常方便。所以,我的问题是:如何在创建Jar文件时手动选择它。



感谢:)

解决方案

Eclipse会设置你告诉的类它设置。向导有一个按钮来执行此操作。

菜单:




  • 导出

  • Java,JAR文件

  • 下一步(选择要包含的类)

  • 输入jar的名称和路径

  • 下一页(

  • 下一页

  • 浏览主课。



或者如果您改为创建Runnable JAR




  • 导出

  • Java,Runnable JAR文件

  • 启动配置 - 这里选择你的主要类。


I have java project, and many class that have main method (just for testing purpose). When I create executable jar file by Eclipse, Eclipse will automatically selects which file is main class. (and often wrong).

There is another way is change main class in manifest file in Jar file. But, it's so handy. So, my question is : how to choose this manually when create Jar file.

Thanks :)

解决方案

Eclipse will set the class you tell it to set. The wizard has a button for doing this.
Menus:

  • Export
  • Java, JAR file
  • Next (select classes to be included)
  • Enter name and path for jar
  • Next (not finish)
  • Next
  • Browse for main class.

Or if you instead create a "Runnable JAR"

  • Export
  • Java, Runnable JAR File
  • Launch configuration -- here select your main class.

这篇关于Eclipse:手动选择可执行jar文件的main类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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