Eclipse:在导出为可运行 jar 时包含源代码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12483771/
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-09-19 19:00:27  来源:igfitidea点击:

Eclipse: include source code while exporting as runnable jar

eclipsejar

提问by thedan

I understand how to include other needed libraries or outside resources while creating a runnable .jar file in eclipse, but what I don't see is an option to also include the src .java files as well.

我了解如何在 eclipse 中创建可运行的 .jar 文件时包含其他需要的库或外部资源,但我没有看到一个选项也包括 src .java 文件。

How could I accomplish this?

我怎么能做到这一点?

采纳答案by aleroot

In the Export --> Jar Filedialog you have the option to incluse source files and resources.

Export --> Jar File对话框中,您可以选择包含源文件和资源。

enter image description here

在此处输入图片说明

To make runnable a standard Jar File you only need to add/include an appropiate MANIFEST.MFon your own ...

要使标准 Jar 文件可运行,您只需要自己添加/包含一个适当的MANIFEST.MF...

回答by Hanumanth

Export to Runnable jar. Open the Runnable Jar with WinRAR. Click Add button, select the src.zip file.

导出到 Runnable jar。使用 WinRAR 打开 Runnable Jar。单击添加按钮,选择 src.zip 文件。

回答by Anly

I know this is answer is very late, but for those who still read this:

我知道这是一个很晚的答案,但对于那些仍然阅读这篇文章的人:

Eclipse has this option. You probably just did not notice it. I haven't checked since what version, Eclipse Luna has it for sure.

Eclipse 有这个选项。你可能只是没有注意到它。我没有检查从哪个版本开始,Eclipse Luna 肯定有。

  • Export --> Jar File
  • then do not click Finish, but click Next.
  • You have more options there.
  • You will probably have to click Nexttwice to get to the Main Classselection.
  • Export --> Jar File
  • 然后不要点击Finish,而是点击Next
  • 你有更多的选择。
  • 您可能需要单击Next两次才能进入Main Class选择。