Python Forum

Full Version: Run Script written in javascript from python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone !!

I have written a scipt for a program called Javafoil and I want torun it from python.
I Therefore write this command in the python console :

java -cp "java\javafoil.jar;java\mhclasses.jar" "MH.JavaFoil.JavaFoil" Script=Script_Javafoil.jfscript
But I have an error :

Error:
java -cp "java\javafoil.jar;java\mhclasses.jar" "MH.JavaFoil.JavaFoil" Script=Script_Javafoil.jfscript ^ SyntaxError: invalid syntax
I have to admit that this command line was given to me and that I don't really get how it works ...
Can someone help and explain ?

Thanks a lot !!
Scientifix
You can try
>>> s = 'java -cp "java\javafoil.jar;java\mhclasses.jar" "MH.JavaFoil.JavaFoil" Script=Script_Javafoil.jfscript'
>>> import shlex
>>> command = shlex.split(s)
>>> import subprocess as sp
>>> sp.call(command)
Tanks Gribouillis !!

But when I run your code I get :
Error:
Error: Could not find or load main class MH.JavaFoil.JavaFoil
What's wrong ? Can you explain me the different parts of a command line such as : java -cp "java\javafoil.jar;java\mhclasses.jar" "MH.JavaFoil.JavaFoil" Script=Script_Javafoil.jfscript ? Maybe it could help ...
(Apr-28-2018, 04:53 PM)Scientifix Wrote: [ -> ]Can you explain me the different parts of a command line such as : java
This is not a python question: your question is about the syntax of the java command. You could read this or type java -h
or man java in a terminal/console. The exact syntax may depond on your os. For example I read that in linux, the ; in your command must be replaced with :.