简体   繁体   中英

Is there any way to launch an “empty” JVM instance without giving it a Main class to run?

For example, just to test that a given set of VM parameters "work" and are valid.

I could always make a class with an empty main method or something, but then I have to worry about the classpath and all that jazz, which it'd be nice to avoid.

If you don't want to specify a long classpath, just make an empty java program in whatever directory you're starting the VM from in terminal. You can do that from within the terminal with vi.

You can just execute java -version and add any set of VM parameters that you like. This will parse the parameters and instantiate a VM instance.

For example: java -version -Xmn64m .

You can also do java -Xmn64m abc where abc is a random string. This will report that it could not find the main class "abc" but it will still first parse the Java parameters and instantiate a VM instance. It actually is supposed to execute slightly more initialization tasks than the java -version does so it is good for testing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM