ADelPino

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2018-07-13
18:55
989 views
Calling a Java class with Pyton Script
Hello. I'm using python script in SUSE linux for get attributes from the conector
In the modify.py script, I made a function for call a java class.
When I call this java class in the modify.py this error appears: " Could not find or load main class HelloWorld"(HelloWorld is the class)
This is the code I have:
import subprocess
def call_java():
return_call = subprocess.Popen (['java', 'HelloWorld'], stdout=subprocess.PIPE)
readClass = return_call.communicate()[0]
return readClass
javaClass = call_java()
I ran the same code in another script with the linux console, and it works.
I have the JAVA_HOME, PATH, CLASSPATH already set.
There's any solution or I need to changes python for another tecnologic ?
In the modify.py script, I made a function for call a java class.
When I call this java class in the modify.py this error appears: " Could not find or load main class HelloWorld"(HelloWorld is the class)
This is the code I have:
import subprocess
def call_java():
return_call = subprocess.Popen (['java', 'HelloWorld'], stdout=subprocess.PIPE)
readClass = return_call.communicate()[0]
return readClass
javaClass = call_java()
I ran the same code in another script with the linux console, and it works.
I have the JAVA_HOME, PATH, CLASSPATH already set.
There's any solution or I need to changes python for another tecnologic ?
2 Replies


Knowledge Partner
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2018-07-13
19:12
This forum is meant for the Identity Manage (IDM) engine and drivers,
which does not sound like something you are using. You may find better
help in a SUSE forum (https://forums.suse.com/).
With that written, you may find good luck using something like strace to
see what the call really, no honestly, looks like to the computer.
If I were you, I would put your class into a JAR and then specify that
with java using the -cp argument, which means that the use of the
HellowWorld class should work more reliably, even if you do not have the
directory structure setup properly, or the CLASSPATH environment variable
set properly.
What are your PATH, JAVA_HOME, and CLASSPATH variables set to, and how do
you know they are set to that at the time you call the java binary from
Python? Do those environment variables get set by Python, or get set
through Python?
--
Good luck.
If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below.
If you want to send me a private message, please let me know in the
forum as I do not use the web interface often.
which does not sound like something you are using. You may find better
help in a SUSE forum (https://forums.suse.com/).
With that written, you may find good luck using something like strace to
see what the call really, no honestly, looks like to the computer.
If I were you, I would put your class into a JAR and then specify that
with java using the -cp argument, which means that the use of the
HellowWorld class should work more reliably, even if you do not have the
directory structure setup properly, or the CLASSPATH environment variable
set properly.
What are your PATH, JAVA_HOME, and CLASSPATH variables set to, and how do
you know they are set to that at the time you call the java binary from
Python? Do those environment variables get set by Python, or get set
through Python?
--
Good luck.
If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below.
If you want to send me a private message, please let me know in the
forum as I do not use the web interface often.


Knowledge Partner
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2018-07-13
19:55
ab;2484021 wrote:
This forum is meant for the Identity Manage (IDM) engine and drivers,
which does not sound like something you are using. You may find better
help in a SUSE forum (https://forums.suse.com/).
Could be he's using the scripting driver...