how to execute a simple display without a main method
this example will show you how, i got this code from the net, and i hope someone will support this, i just like to share this tricky way on how to execure something WITHOUT A MAIN method
Code :
public class NoMain {
static {
System.out.println("No Main!");
System.exit(0);
}
}
i tried to run this in my IDE, but the JVM complies that the class dont have any methods
try to run it in a command - line.. you will see that it will execute normally like any other class with main
Re: how to execute a simple display without a main method
This is not good practise I have to say, usually you use the static blocks to initialise static variables.
// Json
Re: how to execute a simple display without a main method
tnx for letting me know that sir json... its been a while :),
i just got this from a trivia in other posts, i thought this one could be usefull , i was surprised that a user can execute a code without a main method, so i thought this is valid in java practices,,
Re: how to execute a simple display without a main method
Also static blocks are good for loading external DLLs
Re: how to execute a simple display without a main method
::GASP:: You said the d-word! DLL's are purely for programming on windows platforms (though, I do believe there is a comparable feature in both linux and osx)
Re: how to execute a simple display without a main method
Quote:
Originally Posted by
helloworld922
::GASP:: You said the d-word! DLL's are purely for programming on windows platforms (though, I do believe there is a comparable feature in both linux and osx)
I had JNI in mind for Windows lol! I know its not cross- compatable but hey ho, its still true.
Perhaps I should have said, precompiled external libraries