Executing Java programs through Python [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
How do I do this?

You can execute anything you want from Python with the os.system() function.
os.system(command)
Execute the command
(a string) in a subshell. This is
implemented by calling the Standard C
function system, and has the same
limitations. Changes to os.environ,
sys.stdin, etc. are not reflected in
the environment of the executed
command.
For more power and flexibility you will want to look at the subprocess module:
The subprocess module allows you to
spawn new processes, connect to their
input/output/error pipes, and obtain
their return codes.

Of course, Jython allows you to use Java classes from within Python. It's an alternate way of looking at it that would allow much tighter integration of the Java code.

Related

Threre is a fast way to communicate between Java and Python with web except for socket? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I tried using socket. It worked great, and was fast, but I could not read the data from the python server using java. So I want to know if there is a fast way available in both python and java.
Is there a fast way to transfer data over the internet between Java program and Python??
Jython
Run Python code on the JVM using Jython. Have access to Python from Java code, and access to Java from Python code.
See Jython.org.

Can I code a Java program that will call a program in another language (Rust) to do some calculations? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I'd like to make a simulation, but I'd like to write the code to display the state of the simulation and the user interaction (frontend?) in Java (Kotlin actually, but I don't think it is relevant here) for the JVM, and I'd like to write the actual code of the simulation (backend?) in Rust. Mostly because I think it would be neat and that I would learn something.
Can I achieve this, and if yes, how? It might be relevant that the data that needs to be exchanged between the two programs is just a fixed-size array of floats.
Thank you for your help.
A Rust program compiles to native code (executable or shared library). To call native code from Java you have to use JNI: https://www.baeldung.com/jni.
You may find the jni crate useful for the Rust side of the project: https://docs.rs/jni/0.16.0/jni/

What is the java equivalent for Perl's require command? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am completely new to cgi concepts.
I'm given a task to convert a Perl cgi script to Java program.
I understood that the require 'file.ext' command in Perl includes the file available for code in the Perl script.
Because of the very limited resources and improper documentation I couldn't find any proper info.
Is there any Java equivalent to do the same action that require in Perl does?
The paradigms do not map at all. In Perl, require simply reads a file and runs the code in it, and everything else happens as side effects of that. In Java, your code must be compiled, and classes are included automatically when you compile your program. See Extend a java class from one file in another java file for more answers on this topic.

Internal Java Language? (Language run within java) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have started a large project, and require some sort of scripting language that can be stored as plain text, and ran within the JVM very fast during execution. I require a language that is simple, customizable, has various Java API's/Libraries to interpret, and can be stored within a large XML file either in an attribute or the inside of a XML node.
This is required so my program can dynamically write code that it will use later, in a neural network.
LUA is the perfect fit for an interpreted language that you want embed in Java:
http://lua-users.org/wiki/LuaImplementations
A more mainstream possibility is to call Jython from Java:
http://www.jython.org/jythonbook/en/1.0/JythonAndJavaIntegration.html
Another possibility is to use Java only and invoke the compiler at run time:
http://stackoverflow.com/questions/2946338/how-do-i-programmatically-compile-and-instantiate-a-java-class
Using an interpreted language will start the exection of the script faster but the execution itself will be slower. Using the Java compiler will cost more upfront but the execution will be faster and you will be sticking to a single language.

Execute Powershell script using java [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 months ago.
Improve this question
I want to execute powershell cmdlets using java . Is there any way i can implement this?
I tried using Runtime and exec commands but output window hangs in between.
It's easier to use the newer ProcessBuilder class. Runtime.exec has several pitfalls that you need to remember, in order for things to work correctly. For example you need to make sure that the input and outputstreams to the process are handled correctly.
I suggest you google for an example on using ProcessBuilder.

Categories

Resources