You can do this by implementing a native custom launcher as described here:
- http://www2.sys-con.com/itsg/virtualcd/java/archives/0709/chamberlain/index.html
But frankly, it is not worth the effort if you simply want to use a different convention for the entry point. A simpler approach is to write a "proxy" entry point class with a conventional main
method, have that find / load / call your "real" entry point.
On the other hand, if your goal is to execute some code before the main
method gets called, one trick is to put the code into a static initializer block in the entry point class. For example:
public class Entry {
static {
System.out.println("Hello world");
}
public static void main(String[] args) {
// ...
}
}
will print "Hello world" before the main
method is called.
Speculation! It might also be possible identify the hidden Java bootstrapping class that finds / loads / calls the normal entrypoint class. Then you could replace it by adding a modified version to the bootstrap classpath. However, you will be straying into dangerous territory. Interference with hidden mechanisms is liable to end badly if you get it wrong.