1

i am trying to build an online java compiler , written in jsp , where server end accepts uploaded code from clients , compile them and then run the codes and finally prints the output to the user to html forms. i wrote a code that creates a temporary java file (temp.java) contains the code from client , then compile it , creating the (temp.class) file , the problem is in the final step when i try to execute the file , it runs fine when i use the local machine cmd :

java temp

but when i call the command on the server using the java runTime like this :

Process proc = Runtime.getRuntime().exec("java testing/temp");

the output is :

Error: Could not find or load main class temp

the problem is , the runtime cant find the binary file.. what is the path then ? the compiler is in a package that contains the java files , while the clients binary files are createdand stored in a folder (testing) in build/web ..

2
  • This sounds like a fantastically bad idea. I give you ten minutes before you're pwned. Commented Jan 18, 2016 at 22:56
  • okay then how a good idea can work here ? i have no idea about how online compilers work , Commented Jan 18, 2016 at 23:06

1 Answer 1

1

Try to provide full path to your class. I think it should help.

Sign up to request clarification or add additional context in comments.

1 Comment

i tried to get the full path using this : String absoluteDiskPath = getServletContext().getRealPath("/testing"); but it didnt work either ..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.