How can I create a java GUI so when I double click a .jar it launches a java GUI that acts like a console
I have some code that requires input and output and I want to make this into a .jar file that when double clicked can launch a GUI console like application that will work with my code.
The closest I've been able to find is this Create Java console inside a GUI panel But this doesn't really help because I also want the user to be able to input.
Lets 开发者_开发百科say I have this code below
import java.util.Scanner;
public class Name {
public static void main(String[] args) {
Scanner x = new Scanner(System.in);
System.out.println("Please enter your name: ");
String name = x.nextLine();
System.out.println(name);
}
}
I want this to be able to be run in a console like environment but through a java GUI so I can use a .jar file. And please don't recommend a batch file because that is not what I'm looking for.
For the code above here is exactly what I want. I want to be able to have this work exactly how it would normally when double clicked on as a batch file. Except I want it to be executed from a .jar file so I could just double click that and launch it from a mac or a pc in any directory.
精彩评论