“java” succeeds,“ java emmarun” fails

会有一股神秘感。 提交于 2019-12-11 18:17:28

问题


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.



来源:https://stackoverflow.com/questions/7549362/java-succeeds-java-emmarun-fails

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!