Monday, 15 August 2022

b'Error could not find or load main class caused by java.lang.classnotfoundation error'

I am trying to read the executable jar file using python. That jar file doesn't have any java files. It contains only class and JSON files.

So what I tried is

from subprocess import Popen,PIPE

jar_location = C:\\users\app\\my_file.jar"
inputs = C:\\users\\app\my_input.json"

my_data = Popen(["java", "-cp",jar_location,"SOMECLASS.class",inputs])
stdout,stderr = my_data.communicate()
print(stdout,stderr)

What my expected output is, it reads the input(inputs) and passes it to the given class method(someclass.class) and it should return some response for me.

But the actual output I am getting is a Class file not found error.

The class file is inside the jar file only

I tried with Popen(["java",""-jar",jar_location,inputs]), I am getting no main manifest attribute found. I can see a manifest file with the basic version.

Can someone help me how to read these class files through python? I have to do the same thing for multiple class files which are inside the jar file



from b'Error could not find or load main class caused by java.lang.classnotfoundation error'

No comments:

Post a Comment