“java” succeeds,“ java emmarun” fails

2019-09-11 05:36发布

问题:

Disclaimer: I am new to java and emma. Details:

  • I installed emma, and have worked through some of the examples. No problems.
  • I have a java project with a number of files that I wish to get a coverage report.
  • I type "javac -d out *.java". No errors.
  • I type "java -cp out Main". The program runs fine and I get the expected output.
  • I type "java emmarun -cp out Main". I get the following:

    emmarun: [MAIN_METHOD_NOT_FOUND] application class [Main] does not have a runnable public main() method Exception in thread "main" com.vladium.emma.EMMARuntimeException: [MAIN_METHOD_NOT_FOUND] application class [Main] does not have a runnable public main() method at com.vladium.emma.rt.AppRunner._run(AppRunner.java:546) at com.vladium.emma.rt.AppRunner.run(AppRunner.java:97) at com.vladium.emma.runCommand.run(runCommand.java:247) at emmarun.main(emmarun.java:27) Caused by: java.lang.IllegalAccessException: Class com.vladium.emma.rt.AppRunner$Invoker can not access a member of clas s Main with modifiers "public static" at sun.reflect.Reflection.ensureMemberAccess(Unknown Source) at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(Unknown Source) at java.lang.reflect.AccessibleObject.checkAccess(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.vladium.emma.rt.AppRunner$Invoker.run(AppRunner.java:655) at java.lang.Thread.run(Unknown Source)

My "Main.java" file looks like this:

public class Main {
    public static void main( String[] args ) {
        NetworkSimplexTest nst = new NetworkSimplexTest();
        nst.test();
    }
}

I would post all the code, but it is rather lengthy. The simpler examples I tried work fine - emma automatically instruments and creates a coverage report, just like in the examples.

It appears that Emma cannot find my "Main", but regular java can. What am I missing?

回答1:

Emma will expect the class to be defined as public, which was missing in your original code.



标签: java emma