This question already has answers here:
Calling Python in Java?
(12 answers)
Closed 8 years ago.
I have a java web app where i need to use a simple web crawler to read html from webpages. I could not find any simple solution for this in java. But got a very simple python script that solve my problem. Now how to call that python script (.py) from my java class and also get the returned value from the python script .Thanks in advance .
First check out Calling Python in Java?
Another approach might be to call the python interpreter from the command line with a Java Process. See Java Process with Input/Output Stream and Call python script within java code (runtime.exec)
Related
This question already has answers here:
Propagate all arguments in a Bash shell script
(12 answers)
Closed 3 years ago.
From a shell script, I would like to call a shell script which calls a java program. The parameters to the java program are passed from the first shell script.
shellscript1 --> shellscript2 (set par1) --> Java par1
I have tried to source shellscript2 in shellscript1. Still couldnt pass parameters. I dont want to export the parameters and call shellscript2
Any ideas appreciated
Do not use shellscript 2 but add the param to shellscript 1. Using 2 shellscripts makes it complex.
This question already has answers here:
Is it possible to run C source code from Java?
(4 answers)
Closed 7 years ago.
I want to make a Java app that uses the Razer Chroma SDK, but the Chroma SDK is in c++
Is there a way I can run c++ code from Java?
I must use Java for what I want to make.
I have almost no experience in c++, but I understand enough to get doing what I need.
EDIT:
This question is slightly different then others, because it is about a specific SDK, not about general c++ libraries. For this library I was able to use a simpler approach then learning to use things like JNI
You probably want to look into using JNI
The easiest way I found, and then one that doesn't require learning stuff like JNI:
Create a console application with commands that fire off what you need
In Java, launch the console application and redirect it's input and output streams so you can send it commands, and log it's output (see 12013910)
Have a command in the console application that you can pass a PID, and have the console application watch for when it closes, and then it will close itself. (This fixes having the console application not being closed if the Java application crashes and doesn't call the closing method(s))
This question already has answers here:
Run Java class file from PHP script on a website
(5 answers)
Closed 8 years ago.
i have a PHP script which is provide to my one of the friend he is java developer.
that script is on class which is in java language.
i need to run that java program to complete my task. i need to run sum action once in day, and perform sum logical action and updated my data in database everyday.
Please let me know i to do it in php.
here is my java program code.
Run it the way you would run any command line program
var_dump(exec('java yourprogram'));
Perhaps in my opinion the best way would be as follows:
Run your java application on your server with another port (say port 1212)
If it is not needed outside your web server, better restrict the apache tomcat server not to expose port 1212 to anyone outside localhost (you can achieve it with iptables on linux)
Now from PHP, make CURL calls to your java application like http://localhost:1212/my_jar_code.jsp
Use it like web services, problem solved!
In this way your java code will be independent of your php code and you have complete compatibility and power on both java and php codes.
This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
How to execute java program using python considering inputs and outputs both
I want my python variable should receive all the output of java program and using that variable i will display the output on the screen. also if there is a input to java program, I want that user will enter the input which will be stored in my python variable and using this variable, I want to pass the input to java program.. What should I do?? Please help..
Consider using Jython instead, it was designed with Python-Java interoperability in mind. Alternatively, use the standard input/output facilities of the operating system for writing strings back and forth between the two programs, take a look at this post.
This question already exists:
Closed 12 years ago.
Possible Duplicate:
Java REPL shell
Hey,
Is there any way to execute Java code (as you type) on a command line?
For instance, something like this
(command line)
java
import ARDrone;
ARDrone drone = new ARDrone(null, null, null);
drone.takeoff();
(so that you can enter lines of code in the command line)
Groovy can do that. It's possible with java syntax and groovy syntax.
You can try at Groovy web console. You have also groovy console and groovy shell.
You are looking for an interpreter.
Google tells me that BeanShell appears to be one, although I don't know Java and have never heard of BeanShell.