How to use cmd prompt inside Eclipse?

Quick tip As a part of our Quick Tips series we will show in this article how to use command prompt from inside Eclipse tool.There are times when we need to use the Windows command prompt for executing standalone Java programs. On the other hand you need to also use the eclipse for doing the development. So frustrating to switch isn’t it. Well, Eclipse tool actually gives us that option to use the windows command prompt inside Eclipse.

Step 1:  Setup a new External Configuration Tool

In the Eclipse tool go to Run -> External Tools -> External Tools Configurations option.

Step1 External Tool Option

Step1 External Tool Option in Eclipse

Step 2: Click New Launch Configuration option in Create, manage and run configuration screen

Step2 New Configuration Option

Step2 New Configuration Option

Step 3: New Configuration screen for configuring the command prompt

Step3 New Configuration Launched

Step3 New Configuration Launched

Step 4: Provide configuration details of the Command Prompt in the Main tab

  • Name: <<Give any name to your configuration (Here it is Command_Prompt)
  • Location: <<Location of the CMD.exe in your Windows>>
  • Working Directory: <<Any directory where you want to point the Command prompt>>

Step4 Configure CMD Location

Step4 Configure CMD Location

Step 5: Tick the check box Allocate console
This will ensure the eclipse console is being used as the command prompt for any input or output.

Step5 Allocate Console

Step5 Allocate Console

Step 6: Click Run and you are there!! You will land up in the C: directory as a working directory

Step6 Command Prompt with default working directory

Step6 Command Prompt with default working directory

Step 7: Sample commands in the Eclipse console.

Step7 Run CMD Commands

Step7 Run CMD Commands

That’s it. Please provide your feedback and comment if this tip is useful for you.

13 Responses to “How to use cmd prompt inside Eclipse?”

  1. Dev

    Mar 26. 2012

    Good idea! thx

    Reply to this comment
  2. eclipse shortcuts

    Mar 27. 2012

    absolutely loved it. Indeed a great tip, worth including in list of 10 useful java eclipse tips

    Reply to this comment
  3. eclipse shortcuts

    Mar 27. 2012

    absolutely great tip, loved it.

    Reply to this comment
  4. Daniel Schneller

    Mar 27. 2012

    Excellent idea, simple, but effective. I wonder why this hasn’t been seen anywhere before.

    Reply to this comment
  5. Spencer K

    Mar 27. 2012

    Definitely a different and interesting approach, though the lack of response between cmd.exe and the Console is annoying (cls doesn’t work for instance, and the caret jumps around the console).

    You can also improve on this by setting the Working Directory to either of the Eclipse variables “${workspace_loc}” or “${project_loc}”, which will automatically change the directory for you.

    Reply to this comment
  6. Gasbag Architect

    Mar 27. 2012

    Elite programmers don’t need IDEs. This hack is completely unnecessary.

    Reply to this comment
  7. phoenix

    Feb 18. 2013

    useful

    Reply to this comment
  8. indrajith

    Aug 08. 2013

    nice

    Reply to this comment
  9. mark scovel

    Oct 18. 2013

    Well done. Thanks for that.

    Reply to this comment
  10. coder

    Feb 28. 2014

    Excellent… thanks

    Reply to this comment
  11. Marwa

    Jun 19. 2014

    Thank you.. very useful..

    Reply to this comment
  12. Ashish Mali

    Jul 23. 2014

    Thanx a Ton!! :)

    Reply to this comment

Leave a Reply