0

I'm trying to make an online compiler for java using ASP.NET C#

Process p=new Process();
p.StartInfo.FileName = "C:\\Program files\\Java\\bin\\javac.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.Arguments = "C:\\Hello.java";
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardOutput.ReadToEnd();
p.WaitForExit();

I run javac.exe to compile Hello.java, but the process isn't allowed by ASP.NET to write Hello.class to disk

But on doing it manually through cmd.exe without using ASP.NET or progmatically using C# only it runs perfectly

Can you help me make an online java compiler using ASP.NET or PHP for compiling Algorithmic assignments?

4 Answers 4

3

This is a permissions problem - you have two options:

  • Change the application pool identity to an account that has write permissions
  • Give write permissions to the current application pool identity account
Sign up to request clarification or add additional context in comments.

Comments

0

you should configure the access rights for the ASPNET user, this changes a bit depending on which version of IIS and Windows Server the web application runs.

Consider to store the output data locally on the server's disk on a proper location, not directly C or any system folder. let's say C:\JavaOutput\ then give read/write permissions to the ASPNET user to that folder.

Comments

0

This is a permission problem. You need to allow full permissions to c:\ for the ASP.NET USER\IISUSER. That's obviously a WRONG approach.

Your working directory should be the directory in which your web application sits.

Comments

0

Where on the disk does the compiler try to store Hello.class? Chances are, it's in a folder where the ASP.NET process has no permissions to write.

Some tips:

1) Find out what permissions the ASP.NET worker process has. If using IIS, check out the identity of the ApplicationPool it's running under. Chances are it's running under a limited profile.

2) Find a folder where the ASP.NET worker process can write to. This should probably be in a directory under the application root (~), or in some TEMP folder.

3) Check if the javac command-line allows you to specify an explicit output directory. If not, use p.StartInfo.WorkingDirectory to specify a working folder for the process, which will probably make javac output to the specified folder.

Comments

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.