I have a program written in Java and a native launcher written in C++, based on a sample at http://www.codeproject.com/Articles/17352/JVM-Launcher . A strange thing is that running my program with my native launcher take more CPU than using java.exe
(~5% vs 15-20%). I have been giving this situation some thought but it still doesn't make much sense. I've tried increasing the JVM heap size, (re)built the native launcher in release mode, used different JRE version(1.6_24, 1.6_31, 1.7_03) but no luck.
Does anybody have a suggestion for how to fix this?
Source: Tips4all, CCNA FINAL EXAM
Note: Providing this answer to move the OP's comment to answer.
ReplyDeleteThe problem was that the C++ program was running the native launcher with the -Djava.compiler=NONE setting, which essentially set the JVM to run in "interpretive" mode, disabling JIT (just-in-time) compilation of java bytecode to native code, which naturally makes run slower as the bytecode needs to be interpreted every time it is executed.