Sorry for not replying sooner; I've been very busy.
As far as I know Eclipse won't open a command prompt to run Java in. It just uses it's built in console. It would be possible to get your Java program to launch the command prompt and then run another Java program inside that. But I'd need to take a while to work that one out as it's been some time ince I properly used Java.
However, if you wanted to use Eclipse to write Java code and then run it yourself in your own command prompt then that's easy...
Firstly it's useful to understand what Eclipse (or any IDE) is doing when it 'compiles' Java code. It's actually just calling the
javac compiler which is part of the Java Development Kit. Javac will take source code and create bytecode in the form of
class files (it can also create jar and war files which are a collection of class files, but that's a little more advanced). Let's take this example helloworld code:
Code:
public class helloworld {
public static void main(String[] args) {
System.out.println("Hello world");
}
}
This would be saved as a file called hellowold.java. When you save it in Eclipse it will automatically be compiled to a new file called
helloworld.class (you could also do this manually if you install the JDK and simply type javac helloworld.java in the command prompt). Eclipse will save this class file in your workspace directory under a new sub-directoy called
bin.
So in order to run that helloworld java program from the command prompt you need to do the following:
1) Save the file in Eclipse so that it creates a
class file (or compile it manually using the JDK javac command).
2) Find where Eclipse has created the class file. For example if your Eclispe workspace dircetory is c:\workspaces and your project name is Project1 then Eclipse will probably save it as c:\workspaces\Projet1\bin\hellowworld.class
3) Open a command prompt. Make sure you have Java installed (see below)
.
4) type
cd java c:\workspaces\Project1\bin (or wherever your class file is)
5) type
java helloworld (don't add .class on the end, leave that out because java knows it should be a .class)
How to Check If You Have Java Installed
1) Open a command prompt and type
java --version
2) If the command can't be found then you need to download java from
www.java.com