execute method in cmd without main function

266 Views Asked by At

I need to execute a method in .java or .class but this class doesn't have a main function (I can't use main function because it has no return value) I must execute this method in cmd , Is there any way to resolve this problem ?

2

There are 2 best solutions below

0
On BEST ANSWER

If you want to call Java class from Python and get result from it, then you should use something like JPype or Pyjnius.

See Calling Java from Python

2
On

First of all: Java has methods, not functions.

Up until Java 7, it was possible to run Java without a main method using the static block, but this was removed as of Java 7, because the static block was not supposed to use this way.

If you want to run it: add a main method.