Dilber
Dilber

Reputation: 38

Running a java .class program on an HTML page (not a JApplet) like in Eclipse console?

I have a program that I created in Eclipse that I want to be able to run in HTML, however that program is not a JApplet. I was wondering if there was a way to create a console where the user can input information and the program will be able to read it and run the java classes as if it were in Eclipse?

If that isn't clear enough here's a general example: You have the main method which is the executable

public static void main(String[] args){…}

And within that method you call multiple classes

public class Car1 {…}
public class Car2 {…}
etc.

In the main method, a Scanner is built to take in user input

Scanner scan = new Scanner(System.in);

And finally the program runs and takes in info using the scanner, prompting the user what to type in.

Is there a way to run that main program as a Java program (like Eclipse does), but in a webpage (preferably using HTML or HTML5, but other languages welcome)?

Upvotes: 1

Views: 1641

Answers (2)

Nathaniel Johnson
Nathaniel Johnson

Reputation: 4839

I think that you might find a way to make your Java program run using GWT which is Google's version of Java for web pages. A word of warning though. It is a robust framework and though Google says it will continue to support the project, a number of the engineers have moved over to Googles Dart project. The website is here: http://www.gwtproject.org/

Upvotes: 0

anon
anon

Reputation: 21

You could use HTML/Javascript to get the input from the user and send it to a server with AJAX. Then on the server, you could execute the relevant Java based on what the user sent you.

Executing Java not in an applet sounds like it would be difficult to implement and a security risk.

I don't think you want something similar to these websites. http://www.compileonline.com/compile_java_online.php http://ideone.com/

Upvotes: 2

Related Questions