ADelPino Absent Member.
Absent Member.
845 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 ?
Labels (1)
0 Likes
2 Replies
Knowledge Partner
Knowledge Partner

Re: Calling a Java class with Pyton Script

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.
0 Likes
Knowledge Partner
Knowledge Partner

Re: Calling a Java class with Pyton Script

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...
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.