I
I
Igor_ku2019-03-20 18:46:43
Java
Igor_ku, 2019-03-20 18:46:43

How does javaRush, Codecademy work?

Hello!

Interested in such a simple (or not so) question: how do services like javaRush, Codecademy work? I really wanted to do something similar for educational purposes.

As I see it now:
There is a form where I write code. When the button is clicked, a POST request is sent to the server containing this code. Further, this code must be analyzed or passed through tests. And the result of the tests will be displayed to the user.

The biggest problem I faced was code analysis when the server was running. I use Tomcat & Java Servlets, I analyze the code using Java Reflection, and for the site itself I use JSP (I don't know Spring)

All this fuss with reflection, jsp and servlets is quite dreary. And in the case of several classes that are connected together, I'm generally confused. I always feel like I'm doing something wrong.

So the question is: what technologies does JavaRush use for example? Maybe there is something like ready-made solutions \ engines \ frameworks for implementing my ideas in Java? Thank you in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Robur, 2019-03-20
@Robur

Why do you need to analyze code? what do you want to find in it? If there are syntax errors, run through the compiler, it will tell you everything. Runtime errors will pop up on startup.
This is usually done in a sandbox - you create a safe environment for running the code, run it there, if there are any errors - the compiler or runtime will tell you everything, if not - check the script output and send the result back to the browser.
How to make a sandbox is a separate issue. Perhaps there are some ready-made solutions for running java code in isolation, here Google will help you. For simplicity, I would run in an isolated docker - it's heavy and not too limited there inside, but quickly and reliably. Suitable for educational purposes. You can pile up your own sandbox if you are sure of safety.

B
BMaks_N1, 2019-03-20
@BMaks_N1

You can run croch through ANTLR) write a parser for each task) if the string is parsed correctly, then we try to compile and run through the tests, if everything is ok here, we send that everything is ok) but this is a bit dreary, although if you get used to it)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question