I made this little program for a project I'm working on, and it works as it should when I run from Eclipse. What I would like to do is have a .jar file that I can double click and have it run in my console. I alredy exported as a JAR and a runnable JAR on the Export menu, and both times it launches the Java process in the Task Manager, it uses both CPU and Memory, but nothing shows in my screen. I tried compiling with the command prompt, and it's just the same thing. So, my question is, can I have a stand alone java application without a GUI? Because it seems that's my problem: I followed a tutorial to make a program with one, and it worked just fine.
I'm using Windows 8 64-bit (I have to because of some other software I have to use on my project). I'm a newbie at this Java buissness, so if you can please keep it as simple as possible; I'd really appreciate it. Thanks in advance.
import java.util.Scanner;
public class Distancia {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int check = 1;
System.out.println("Kilómetros a Millas Náuticas\n");
do {
int cm = 0;
int salida = 0;
while (salida != 1){
try {
System.out.println("Escriba la distancia en kilómetros:");
cm = sc.nextInt();
salida = 1;
} catch (Exception e) {
System.out.println("Opción Inválida");
sc = new Scanner(System.in);
sc.reset();
}
} //Fin del While
//Conversiones de distancias
int km = cm*50; // Conversión de Centimetros-mapa a Kilómetros
double mn = km/(1.8); // Conversión a Millas Náuticas
//Cálculos de Velocidades
System.out.println("Distancia en kilómetros: "+km+" km.");
System.out.println("Distancia en millas náuticas: "+mn+" MN.\n");
if (mn/5<24)
System.out.println("Tiempo a 05 nudos: "+mn/5+" horas.");
else{
System.out.println("Tiempo a 05 nudos: "+mn/5+" horas.");
System.out.println("Tiempo a 05 nudos: "+(mn/5)/24+" días.");
System.out.println();
}
if (mn/8<24)
System.out.println("Tiempo a 08 nudos: "+mn/8+" horas.");
else{
System.out.println("Tiempo a 08 nudos: "+mn/8+" horas.");
System.out.println("Tiempo a 08 nudos: "+(mn/8)/24+" días.");
System.out.println();
}
if (mn/12<24){
System.out.println("Tiempo a 12 nudos: "+mn/12+" horas.");
System.out.println();
}
else{
System.out.println("Tiempo a 12 nudos: "+mn/12+" horas.");
System.out.println("Tiempo a 12 nudos: "+(mn/12)/24+" días.");
System.out.println();
}
}
while (check !=0);
sc.close();
}
}