Java Eclipse:导出运行配置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2502518/
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
Eclipse: export running configuration
提问by Hyman
I wrote a complex Java application with eclipse that uses many .jar libraries included into project folder.
我用 Eclipse 编写了一个复杂的 Java 应用程序,它使用了许多包含在项目文件夹中的 .jar 库。
Is there a quick way to export a running configuration of the application that allows me to run it from shell (I don't actually need to move it around machines, so no jar export or similar things).
有没有一种快速的方法来导出应用程序的运行配置,允许我从 shell 运行它(我实际上不需要在机器上移动它,所以没有 jar 导出或类似的东西)。
I just need to detach the execution from Eclipse, but since project has many settings I would like to export a script (maybe .sh or just a plain long line) automatically..
我只需要从 Eclipse 中分离执行,但由于项目有很多设置,我想自动导出一个脚本(可能是 .sh 或只是一个普通的长行)。
采纳答案by Adrian
You can get the full command executed by your configuration on the Debug tab, or more specifically the Debug view.
您可以在 Debug 选项卡或更具体地说是 Debug 视图中获取由您的配置执行的完整命令。
- Run your application
- Go to your Debug perspective
- There should be an entry in there (in the Debug View) for the app you've just executed
- Right-click the node which references java.exe or javaw.exe and select Properties
- In the dialog that pops up you'll see the Command Line which includes all jars, parameters, etc
- 运行您的应用程序
- 转到您的调试透视图
- 您刚刚执行的应用程序应该在那里(在调试视图中)有一个条目
- 右键单击引用 java.exe 或 javaw.exe 的节点并选择属性
- 在弹出的对话框中,您将看到包含所有 jar、参数等的命令行
回答by ring bearer
- Starting with File menu
- File -> Export Expand "General" node
- Choose "Ant Buildfiles" Press "Next"
- You will get a list of projects,
- choose the project you wish to use. Press
- "finish" button As a result,
- you would get an ANT build file, which will have targets that points to your "Run configurations" for the given project.
- 从文件菜单开始
- 文件 -> 导出 展开“常规”节点
- 选择“Ant Buildfiles”按“下一步”
- 你会得到一份项目清单,
- 选择您要使用的项目。按
- “完成”按钮 结果,
- 您将获得一个 ANT 构建文件,其中包含指向给定项目的“运行配置”的目标。
Now, to run a run configuration "run-config-1" you may type on your command line (Assuming you have ant on your shell's PATH)
现在,要运行运行配置“run-config-1”,您可以在命令行中输入(假设您的 shell 的 PATH 上有 ant)
ant run-config-1
回答by VlatkoB
Exporting:
出口:
- Go to File > Export... > Run/Debug > Launch Configurations
- In the dialog select all or what you want
- Set the filename
- 转到文件 > 导出... > 运行/调试 > 启动配置
- 在对话框中选择所有或你想要的
- 设置文件名
Importing:
输入:
- Go to File > Import... > Run/Debug > Launch Configurations
- In the dialog select all or what you want
- Set the filename
- 转到文件 > 导入... > 运行/调试 > 启动配置
- 在对话框中选择所有或你想要的
- 设置文件名
回答by mprivat
- Right click on a project in the Eclipse explorer
- Export...
- Java -> Runnable JAR file
- Pick your launch configuration from the drop down
- Set the export destination
- Optionally, you can export that as an ANT script too
- 在 Eclipse 资源管理器中右键单击一个项目
- 出口...
- Java -> 可运行的 JAR 文件
- 从下拉列表中选择您的启动配置
- 设置导出目的地
- 或者,您也可以将其导出为 ANT 脚本
Done. You get a JAR file you can execute with java -jar yourfile.jar
完毕。你会得到一个可以执行的 JAR 文件java -jar yourfile.jar
Note that if your launcher had command line arguments, they don't get exported, you have to pass them to the java
command.
请注意,如果您的启动器有命令行参数,它们不会被导出,您必须将它们传递给java
命令。