37

Given a "run configuration" in Eclipse, I want to print out the associated shell command that would be used to run it.

For example: Right now, in Eclipse, if I click "play" it will run:

mvn assembly:directory -Dmaven.test.skip=true

I don't see that command, I just know that's what the IDE must run, at some point. However, some of the other run configurations are far more complex with long classpaths and virtual machine options and, frankly, sometimes I have no idea what the equivalent shell command would be (particularly when it comes to Flex).

There must be some way to access the shell command that would be associated with a "Run Configuration" in Eclipse/Flex Builder. This information must be available, which leads me to believe someone has written a plugin to display it. Or maybe there's already an option built into Eclipse for accessing this.

So is there a way to, essentially, convert an Eclipse run configuration into a shell command?

(for context only: I'm asking because I'm writing a bash script that automates everything I do, during development--from populating the Database all the way to opening Firefox and clearing the cache before running the web app. So every command I run from the IDE needs to exist in the script. Some are tricky to figure out.)

splash
  • 13,037
  • 1
  • 44
  • 67
gMale
  • 17,147
  • 17
  • 91
  • 116
  • 2
    It won't necessarily run a shell command. In fact, it almost never will since Eclipse doesn't have a shell or use a shell interpreter. Things like maven and ant have Java hooks which bypass any need for a shell. – Mark Peters Jun 04 '10 at 17:54

3 Answers3

55

This should work for Java and Maven processes. You can get the command line from the Process properties.

  • run the process in debug mode
  • right click on the process item in the "Debug" view and choose "Properties"
  • the command line is displayed
splash
  • 13,037
  • 1
  • 44
  • 67
  • 1
    This is exactly the kind of thing I'm looking for. I tested it in Flash Builder 4 (it's a watered-down eclipse) and it didn't work there but I see how it could work in other situations. So I'll check it in my plain Eclipse when I bring it back up. – gMale Jun 16 '10 at 17:05
  • This works for me, but see miki's answer below as well...the agentlib argument needs to be removed. – Bill Apr 24 '11 at 13:42
  • 1
    Note that you can get it even running in non-debug mode. Also, if you're having trouble finding the process item, it is probably the second item in the "Debug" view tree. – Peter Tseng Jun 26 '13 at 22:54
  • if the process already exited, the inner properties will have such full command line, thx! – Aquarius Power Nov 07 '16 at 19:55
18

Another trick if you're running on a Unix OS (although you have to be snappy about this...) is to initiate your Run.. within Eclipse and then switch over to a command prompt and run this command (Mac syntax):

ps -ef | grep java

This will print out the command line Java process invocations that are currently running. Look for the one that corresponds to your Eclipse process (check the main class, which is the last parameter on the command line) and voila!

Alex
  • 855
  • 7
  • 21
4

thanks so much splash. one thing to add-- i was getting a weird error at the commandline:

ERROR: transport error 202: connect failed: Connection refused ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510) JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:708] FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197) Aborted!

this can be avoided by just taking out the agentlib argument:

-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:56431

miki
  • 71
  • 1
  • 3