59

I wrote a complex Java application with eclipse that uses many .jar libraries included into project folder.

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).

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..

Roman C
  • 49,761
  • 33
  • 66
  • 176
Jack
  • 131,802
  • 30
  • 241
  • 343

4 Answers4

89

Exporting:

  1. Go to File > Export... > Run/Debug > Launch Configurations
  2. In the dialog select all or what you want
  3. Set the filename

Importing:

  1. Go to File > Import... > Run/Debug > Launch Configurations
  2. In the dialog select all or what you want
  3. Set the filename
VlatkoB
  • 1,219
  • 1
  • 12
  • 12
  • 11
    that's for export and import inside eclipse, but the OP wants export from eclipse and run from shell – CharlesB Jan 13 '12 at 14:20
  • 8
    @CharlesB: Several years later this page is not about answering OP's question anymore, it's about answering the question of those who came here clicking "Eclipse: export running configuration" in the search results. For most of us this probably is the more useful answer. – Chei May 12 '14 at 13:32
  • I upped Yours as well - since Yours was very useful - looked at the runner-up after, and he actually took me the last step towards Ant. – user2692263 Feb 17 '17 at 10:36
  • eclipse 2021-09: The dialog lets you choose/define the export folder. The export then creates a file for each selected launch configuaration – Heri Jun 05 '23 at 10:14
  • Import, e.g. by eclipse 2023-03: You choose the folder, the following dialog lets you choose each launch configuration found in the folder individually. – Heri Jun 05 '23 at 11:12
77

You can get the full command executed by your configuration on the Debug tab, or more specifically the Debug view.

  1. Run your application
  2. Go to your Debug perspective
  3. There should be an entry in there (in the Debug View) for the app you've just executed
  4. Right-click the node which references java.exe or javaw.exe and select Properties
  5. In the dialog that pops up you'll see the Command Line which includes all jars, parameters, etc
Adrian
  • 2,123
  • 3
  • 18
  • 24
  • 5
    Is there a way to find the command executed for compiling the project in a similar way? – Bob Mar 01 '15 at 10:12
  • That basically works but it does not do the proper shell-quoting of arguments containing white space or meta characters. – dadaist Sep 30 '22 at 08:49
17
  • 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.

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)

ant run-config-1
ring bearer
  • 20,383
  • 7
  • 59
  • 72
0
  1. Right click on a project in the Eclipse explorer
  2. Export...
  3. Java -> Runnable JAR file
  4. Pick your launch configuration from the drop down
  5. Set the export destination
  6. Optionally, you can export that as an ANT script too

Done. You get a JAR file you can execute with 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.

mprivat
  • 21,582
  • 4
  • 54
  • 64
  • 1
    The OP has already stated that they are looking for running the application "along with the Eclipse settings". I feel the other answers address this concern better. – wavicle Apr 10 '17 at 17:54