Hello guys
I'm new to writing java but have some experience with other languages. I use Eclipse as my IDE but when i try to run a simple console program (exported to .jar using Eclipse) i am only able to run it from the command prompt.
An example of a program that only seems to work in the cmd is:
package main;
import java.util.Scanner;
public class start {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String text;
text = input.nextLine();
System.out.println(text);
}
}
When i doubleclick it in the folder the computer seems to do something but appears finished within a fraction of a second.
The program works when i write the following in cmd:
cd Documents
java -jar test.jar
(It lets you write a line and prints the same line again.)
Can anyone tell me how i make the java program open a console window (cmd or whatever) to let the user enter the data and recieve the answer. And aditionally make it not disappear immediately after finishing the program.
Thanks alot in advance
Emil J.J.