2

I have a Java program that runs from command prompt / blueJ's terminal window fine.

Is there a way that I can run this from a browser?

I guess my question is, is there anything that simulates the terminal window in a browser?

If not, do you have a suggestion as to how to put this online? It uses scanner / system.out.println a lot.

Thank you

Clark
  • 478
  • 6
  • 14

3 Answers3

3

There are two main technologies for helping publish a Java application via a browser:

  • Applets (displays inside a browser, kind of like Flash)
  • Java Web Start (launches via browser, but then runs and displays in a separate window.)

It most most common to use Swing to develop the user interface of an Applet or Java Web Start application. So it might be interesting to read about how to emulate a console window in Swing.

Community
  • 1
  • 1
Mike Clark
  • 10,027
  • 3
  • 40
  • 54
1

I'm not sure if this helps, but when you access a website that uses Java, with your browser, you can decide to see the Java console, if you have it enabled in your Java settings. But only people with that option turned on will get to see it.

Otherwise you could use javascript to incorporate results into the html of the page, or maybe make an applet with a "console" included.

Luis Miguel Serrano
  • 5,029
  • 2
  • 41
  • 41
  • So let's say that I put a .jar file online, if the user set the options up correctly they could just view the console from there? This may be what I'm looking for. – Clark Dec 12 '10 at 05:00
  • Unfortunately I don't think you can give input via the "Java Console." That is, it doesn't do stdin, only stdout. – Mike Clark Dec 12 '10 at 05:08
  • I think you can. This post refers to someone who was making an Applet that manages to read and write to console: http://stackoverflow.com/questions/138157/java-console-like-web-applet – Luis Miguel Serrano Dec 12 '10 at 13:41
  • And @Dave, you shouldn't expect the user to have the console opened. I'm not sure if it will display all that you want, but you shouldn't assume the user has got that settings that way, so, if you really need a console you should most likely have your applet draw it's own console on screen and use a specific method to print to that console instead of to Java's native console. Or, alternatively use javascript to make it more direct possibly. – Luis Miguel Serrano Dec 12 '10 at 13:44
  • Miguel, thank you very much for the link.. I'm going to look into implementing something similar to that. That is the closest thing I've found to a ready-made fix.. Yeah it would be unrealistic to expect the user to have the console open, but I just need a way of demoing it to my instructor for the time being.. – Clark Dec 12 '10 at 17:33
0

You can embed in an applet, not only GUI you can use applets to invoke any method. And you can view console view ,[ Java Icon pops up on system tray bar in windows,on right clicking on the java icon, you can view console ]

Ratna Dinakar
  • 1,573
  • 13
  • 16
  • Thank you for the response. How can I go about doing this? Could you lead me to some documentation.. I'm having trouble finding it. – Clark Dec 12 '10 at 04:56