Call a dockerized python script from another dockerized java application? - java

I need to create a Java application which sends some input parameters to a python script and sends some output back to my java application.
I cannot run the script in my java code using jython Or similar things as the python scripts are build on demand and I may need to add new scripts every now and then. So this should not impact my java app.
My java application will be running on a container and based on a few condition check it might have to select 1 of the py scripts from suppose 100 scripts and run it. And again the condition later on may change and a different script has to run at that time
I went through many websites and tutorials on the net but did not find anything relevant.
Has someone tried anything similar?

Related

How do I make my Java application apple-scriptable

I want to be able to set properties and commands for my Java Swing app. Similar questions have either deferred to using shell scripts or remain unanswered. Looks like normally this is done in Cocoa. Does this mean I need to incorporate Cocoa into my project just to be able to command it through AppleScript? Currently, I cannot even do simple commands such as resizing windows (which I wrongly assumed would work out of the box).

Can Symfony run Java jobs over Beanstalk?

I'm working on a Symfony 3 (PHP) project.
I would like to launch a Java executable using parameters I got from Symfony.
Some informations to consider:
The executable generates a file as an output.
Execution can take several minutes depending on the input parameters.
Multiple users can trigger the execution simultaneously.
I'm looking for a long-term sustainable solution. Do you have any advice?
After some research on queues.io, I found out that Beanstalk for PHP seems to be fitting my needs, but I would like to confirm or infirm this position with you.
What would you do in a similar case?

Running Powershell script from Java project wrapped as a service

I am wrapping two java programs as services using yajsw (yet another java service wrapper) in order to have them run indefinitely on separate servers. I got one of them to work exactly as I expected (the service is installed on a server, behaves exactly as it does when run from cmd and restarts anytime it or the server goes down). However, when I do this with the second java project it does not work. It gets installed as a service and will run, but when it tries to run a powershell script (something the first project does not do) from within java, using ProcessBuilder(), it starts and powershell.exe shows up in task manager, but never closes or produces any of the expected side effects. Both things that work seamlessly when I run the .jar from the command line. Is there something different about the environments that services/processes run in that would explain this?
Update:
Within the script I have the following line:
$outlook = new-object -com outlook.application;
The problem is that $outlook is null after this and the script then fails to parse any emails resulting in no output. What about wrapping the java program as a service would mess up the creation of an outlook application object?

Using a Java program I made on a Web Server

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.
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.

Run Java programs from PHP in a sandbox

I have a little question: we have to run Java programs and parts of the code will be uploaded by the users.
So I want to know what's the best way to run them? I know 2 possible ways,
exec("javac Usercode.class") and then run the whole thing with exec("java Main"), but I tried it with exec() and it don't work. maybe because the http is not root? But I don't know exactly why.
http://php-java-bridge.sourceforge.net/pjb/ ?
Any suggestions?
And another question is, how can I run these programs in a sandbox. we have a Debian server and so it's no problem to execute the command with a limited time, but is there a possible way to run the whole code in a sandbox?
Ideas for sandboxing:
Run in a chroot using e.g. Debian's schroot command. Protects against them accessing files outside of the chroot but not against them doing things like opening sockets etc.
Each user has their own Linux username against which they validate. Commands will then be run under the appropriate username (e.g. by using sudo or a set-uid executable).
Maintain a pool of virtual servers - expensive and complicated but gives best isolation.

Categories