PHP site scheduling Java execution?

I'm trying to get started combining my (slightly limited) PHP experience with my (best) Java experience on a project, where I need to allow the Java source files to be uploaded to the server, which then runs Javac to compile it.

Then, at a given time (like given on load), I need to run it once on the server, which will generate some database information for the rendered PHP site.

To describe my current programming capabilities, I've done a lot of desktop Java programs and I'm confident in "pure" Java, but so far I've only done a few PHP projects (including using the CodeIgniter Framework).

My motivation for using PHP as an interface is because I know that it is very fast, lightweight, and I can easily display the results that I really need (simple database reading). Ideally the technology used should be developed on localhost (e.g. WAMP, Tomcat, etc.).

Is there any advice you could give on what technology should I use to bridge this gap and what resources can help in using this technology? I've looked at a few but struggled to find documentation to help achieve what I need.

+2


a source to share


1 answer


There are many ways to approach this and you haven't given enough detail to narrow down to one path, so I'll suggest a few ... Compiling the java source would probably take too long for a normal web request, so my recommendation would be so that the PHP script that takes in java source files runs a background command that compiles the source files and writes them to the database or log file. So you can redirect the user to a page that says "Please wait, your source is compiling" and use Ajax to check every few seconds to see updated progress. If this is the route you want to go take a look at the PHP exec command .

It may be more useful for PHP to simply create an ID in the database for each uploaded file and call move_uploaded_file to move the source files to the "incoming" directory. From there, the cron job that runs so often can scan the incoming directory or database for source files, compile them, and update the database when finished.



In either of these cases, the program that compiles can be written in any language, even Java if you prefer.

+1


a source







All Articles