Click here to Skip to main content
15,879,053 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm currently accessing JDK that is on my local machine. I want to be able to use it remotely(I want to have a JDK on the server, so that all users can compile and run their codes). I'm thinking of copying it from my local machine to App_Data folder in the .Net project, then right click and include it in the project. Is that correct?

What I have tried:

C#
public ActionResult Compile(string dirPath)
       {
           Process p = new Process();
           p.StartInfo.FileName = "C:/Program Files/Java/jdk1.8.0_20/bin/javac.exe";
           p.StartInfo.UseShellExecute = false;
           p.StartInfo.Arguments = "E:/Atypon/TE4/src/FileServer/Upload.java";
           p.StartInfo.RedirectStandardInput = true;
           p.StartInfo.CreateNoWindow = true;
           p.StartInfo.RedirectStandardOutput = true;
           p.StartInfo.CreateNoWindow = true;
           p.StartInfo.RedirectStandardError = true;
           p.Start();
           string result=p.StandardError.ReadToEnd();
           p.WaitForExit();
           return View(result);
       }
Posted
Updated 9-Apr-17 23:26pm
v2
Comments
Richard MacCutchan 9-Apr-17 12:12pm    
What happens when you try it?
Member 12992094 9-Apr-17 12:16pm    
It compiles correctly, but the path to the JDK is local, so users on other machines can't use it.
Richard MacCutchan 9-Apr-17 12:30pm    
Why would you expect that they could?
Member 12992094 9-Apr-17 12:49pm    
I have to allow them to compile their Java programs without needing to install JDK on their local machines, this is the main point of the website. JDK is a big folder, I can't upload it to the server the same way as I upload a simple txt file. So, I thought of copying it to the project directory. I'm just not sure if it will work.
Afzaal Ahmad Zeeshan 9-Apr-17 19:20pm    
Then just allow them to upload a source input, and compile it on their behalf. That way, the execution will take place online, and they will get the response.

Do not allow the users to interact with binaries on your server, directly. It is totally illogical, and unsafe to allow anyone to access the content — especially the binaries — as it may expose your web application to them, and then results depend entirely on their intentions.

1 solution

Now that you have mentioned the tool you are using, let me walk you through the entire process myself. The thing is, that on a cloud platform you cannot expect to run an installer, even if they let you, the virtual machine will eventually trigger and clean up the temp folders — your content is always in a virtual environment, even if you pay for a physical server.

So, how to get Java JDK on Azure? Well, you already have that... :-)

Azure provides you with all of the libraries that you require, to run an application. Python, Java, Node.js, .NET framework, all of them are supported and provided there, if you dig a bit deeper in the control panel of Azure — I am talking about the Kudu control panel, then you will be able to find that the javac (Java Compiler), and the Java JVM (java.exe) are all provided to you in the machine itself. For instance, go here,
cd D:\Program Files\Java\jdk1.8.0_73\bin

Then, if you do a dir you will see the list of binaries. They contain everything you need to compile the Java code, or run the Java code to show the output.

You would require to access the runtime information, such as environment variables, to determine where these binaries are provided and then target them from within the application.

Your control panel can be easily found at, <your-web-app-name>.scm.azurewebsites.net. You can then go to the Debug console, and roam around your service.

For resources, directly related with Java development on Azure, or the available tools and services, please review the Java developer center | Microsoft Azure[^] documentation.
 
Share this answer
 
v2
Comments
Member 12992094 10-Apr-17 6:02am    
So I have to deploy it to Azure first, then complete the development based on what Azure provides?
Afzaal Ahmad Zeeshan 10-Apr-17 6:05am    
Yes, and no.

Yes, because, of course you have to first deploy the application to Azure.

No, because you can build it any way you want. However, you just have to take care of the locations where binaries are located, to trigger them.
Member 12992094 10-Apr-17 6:41am    
Thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900