2

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.

Community
  • 1
  • 1
JDN
  • 509
  • 3
  • 8
  • 14
  • Why? Why try to force a console like application in an event-driven GUI rather than pure event-driven goodness? – Hovercraft Full Of Eels Oct 02 '11 at 02:17
  • Huh? You can create a GUI with a .jar file. – SLaks Oct 02 '11 at 02:21
  • @SLaks: unless I'm misreading the question, I don't think that that is the issue. To me it seems like he wants to create a GUI that behaves as a console which seems a little odd to me. – Hovercraft Full Of Eels Oct 02 '11 at 02:23
  • @HovercraftFullOfEels: You may be right; it's a very unclear question. However, his mention of a batch file implies that I'm right. Either way, it sounds weird. – SLaks Oct 02 '11 at 02:24
  • If you look at the link to another SO question I provided it might clear it up a little bit. The only problem with that one though is it doesn't let me change the input's standard behavior only the outputs. – JDN Oct 02 '11 at 02:27
  • Use a JTextField for input. It can be placed just below the JTextArea /output window by way of BorderLayout. – Hovercraft Full Of Eels Oct 02 '11 at 02:34
  • @JDN: What is your ultimate intention? From this ... "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." ... I gather that what you actually want is: Make standard Java console applications that can be started by double-clicking a .jar file. Correct? If so: I just created a Java class that makes this possible. http://stackoverflow.com/a/32547250/3500521 – Dreamspace President Sep 13 '15 at 07:29

0 Answers0