2

I created a small application that, when run, creates or updates some tables in a database by extracting data from some PDF files. Everything works fine in this desktop application, but the next step for me would be to make it possible for an administrator on a website to upload a PDF file and my Java program would then run and update the tables accordingly.

The problem is I have no idea where to start with this (the site isn't done yet, but I'm running some tests and it is going to be coded in PHP). I'd like to know what kind of technologies I need to let the server run the program and update everything as it would in the offline version. Sometimes it takes a while to update everything, so ideally, the user uploading the PDF could continue browsing other pages while the server does its job. (I'll probably implement something that when the server is done processing the file, it says if the program ended successfully or not in a log file)

Can someone tell me what terms to search for on Google or give me some pointers? I haven't chosen where my website is going to be hosted either, so if someone could tell me what to look for to know if they support running applications like this, I'd really appreciate it as well!

This could also apply to other programming languages as I know a bit of Python and C++ as well, so in the future I might have some applications in those languages I'll want to use on the web.

If I'm not approaching this the right way, I'm open to other suggestions, but the best solution would be to keep my Java program intact as I know it works exactly like I want it to and I'd rather not have to start it all over again.

1 Answer 1

1

If your host is *NIX based you can use crontab (Automatic Task Scheduler) to run your program at set intervals. Make it check if a "new" PDF exists, and run the program if there is. There may be a way to use Windows Task Scheduler type programs to do it on Windows. This is probably the easiest way.

Alternately you can use You can use shell_exec() in your php to execute a command on your *NIX system directly to run your java program.

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

3 Comments

It's probably going to be UNIX based since most host I've found use that... Do I have to make my program into a servlet as I was reading in another question on SO or is the regular jar enough? The scheduler thing is great (especially for other ideas I have for the future), but I'd like to know if there is a way to call my program manually (ie: when the user clicks the upload button and the file is done uploading). I feel like this second way wouldn't put as much of a load on the server since it would span the parsing over the whole day instead of slowing it down at a given interval.
edited answer. The regular jar can be executed. Parsing even on 1 minute intervals will only be a trivial load on the system, so I would recommend that method as it's probably more secure, though I couldn't tell you how. Running shell commands on a webserver just seems like a bad idea but I can't find literature saying it is.
It makes perfect sense. I'm going to look into it! Thanks a lot for your answer and for your time!

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.