Start Java in your web browser.

Is there a way to run the Java command line on a webpage in the lines of this Ruby webpage:

The goal is to give complete beginners a very simple introduction to the language without having to worry about IDEs, compilation, etc.


source to share

2 answers

Well, since Java is a compiled language and has no REPL , there is no such "command line". But I can think of theoretically possible ways to implement the idea.

  • The applet might not be the solution. I don't know how far you can get limited permissions. Security issues can only allow you to sandbox and / or not compile / execute code.

  • Java WebStart application can have these permissions. It would be a similar challenge to provide a thin IDE. Or create Bluej from WebStart.

  • Providing a web application that simply handles the request to the server, which compiles and runs the code, and returns the result. I assume (I'm not sure) that many online REPLs work like this. (After dropping JavaScript try python I think it handles AJAX requests). But then there is still a security issue, like what if the program starts deleting files randomly? Google Appengine has advanced security mechanisms to prevent misses. Implementing them for "try java" requires additional effort.

  • The next idea is to limit everything to a subset of the Java language. To provide a small introduction, a small tutorial with predefined answers, and maybe some basic math, you can write client-side JavaScript to decide if the student's answers are correct or not.

  • Keep in mind that there are currently web-based IDEs such as Eclipse Orion being developed . Perhaps you could watch these projects develop and use them for this purpose. Currently I have only seen JavaScript code edited there and JS execution is one of the natural features of web browsers. I don't know what programming languages ​​they will support or code execution will be.



But usually java needs to be compiled in order to be useful to the JVM. So I'm not sure if you can do something like this that would be useful for java. The main difference is in interpreted (Ruby) and compiled (java) implementation.

See What is the difference between compiled and interpreted language?



All Articles