running java main class using subprocess.Popen in python -
i want execute java main class main.java python using subprocess.popen(). main.java takes 3 args.
i wonder how it? example have helloworld.java class:
public class helloworld { public static void main(string[] args) { system.out.println("hello world!" + args[0]); } } i tried call in python using command:
print (subprocess.popen('java c:/users/testing/hello.main sayhello', shell=true, stdout=subprocess.pipe).stdout.read())
where 'sayhello' string args want pass in. said
error: not find or load main class c:.users.testing.hello.main
thanks
you may run java file extension .class following way:
java your.path.main arg1 arg2 where,
java- command, runs java interpreteryour.path.main- full name of class (without.class)arg1 arg2- arguments (written spaces or between")
further, when formatted line, transmits in subprocess.popen() argument.
subprocess.popen('java your.path.main arg1 arg2') i'm not python programmer, because advice read documentation method.
Comments
Post a Comment