I'm getting Java code generated for me from an application. I took the JRE and extracted all the files into a new directory. There is a META-INF folder that has a MANIFEST.MF without any main method.
Witin this JRE is the class of the code I'm interested in however when I CMD the following...
java Steve.class
I get this error...
Could not load for find Main Class Steve.class.
I'm assuming that somewhere in all these class files there is a Main class but how do I search all these documents to find it? Is there an application?
Thanks!
You don't need the .class suffix when invoking a Java program. Do it like this:
java Steve
To work out which class has a main method, you can use javap (Java Class File Disassembler) on each class file. For example:
$ javap Foo
Compiled from "Foo.java"
public class Foo extends java.lang.Object{
public Foo();
public static void main(java.lang.String[]);
}
First: every class that exposes this method signature:
public static void main(String[] args) { }
could be a main class launchable from the JVM and eligible to be put in the manifest to enable shell execution.
Second: when you launch a class in a JRE you must specify the fully qualified name of the class; for example if Steve.class file is in a tree structure such as com/mycompany/app, starting from the root of your application where the MANIFEST directory is, you should launch it, from the root directory, typing:
java com.mycompany.app.Steve
So if Steve exposes a main method and if you can correctly point to it from the root, you can launch it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With