19

I have several JUnit run configurations in Eclipse that I need to replicate on the command-line in order to use a third-party analysis tool. So far I've just been writing the command-line manually by looking at the run configuration and writing the appropriate classpath and command-line arguments.

Eclipse's run configurations (normal, JUnit, or other) must ultimately boil down to a command-line anyway, so how and where do I find that?

rob
  • 6,147
  • 2
  • 37
  • 56

4 Answers4

41

I found a solution on Stack Overflow for Java program run configurations which also works for JUnit run configurations.

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 In the dialog that pops up you'll see the Command Line which includes all jars, parameters, etc
Community
  • 1
  • 1
rob
  • 6,147
  • 2
  • 37
  • 56
  • 1
    The reason you likely found one on SO is that tool questions (such as how to do XYZ in Eclipse) generally go to Stack Overflow. We're just a bit short on people who have the ability to do a timely migration to SO today for your question. –  Dec 31 '13 at 21:07
  • @MichaelT thanks; I've had trouble with the distinction between SO and the other SE sites. I assumed everything that does not involve troubleshooting code problems was being offloaded to other SE sites like Programmers and Code Review. I guess I should have taken another look at http://programmers.stackexchange.com/help/on-topic – rob Dec 31 '13 at 21:49
  • 2
    If you glance at [where does my git question go?](http://meta.programmers.stackexchange.com/questions/6311/where-does-my-git-question-go) and the rational behind what goes where, it may help at making a best shot for other questions that *might* go to multiple sites. –  Dec 31 '13 at 21:53
2

You'll find the junit launch commands in .metadata/.plugins/org.eclipse.debug.core/.launches, assuming your Eclipse works like mine does. The files are named {TestClass}.launch.

You will probably also need the .classpath file in the project directory that contains the test class.

Like the run configurations, they're XML files (even if they don't have an xml extension).

Dennis S.
  • 2,081
  • 14
  • 14
2

To elaborate on rob's answer.

Make sure you open the debug view. Steps to open it: Window -> Show View -> Other -> (Search debug) -> Open

Then do what he references:

  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 In the dialog that pops up you'll see the Command Line which includes all jars, parameters, etc

enter image description here

Ynjxsjmh
  • 28,441
  • 6
  • 34
  • 52
0

Scan your workspace .metadata directory for files called *.launch. I forget which plugin directory exactly holds these records, but it might even be the most basic org.eclipse.plugins.core one.

Kilian Foth
  • 13,904
  • 5
  • 39
  • 57
  • 1
    Didn't find any *.launch files in .metadata. My run configurations themselves are saved as *.launch files in my projects but those are in XML and don't contain the raw command that is executed by the shell. Any other ideas? I was thinking the command might be logged somewhere. – rob Dec 31 '13 at 19:35