Almost everywhere in INTERNET there are these basic steps:
• Compile java files as usual
javac <source-files>
• “Instrument” the byte code
java -jar jcov.jar Instr <application classes>
• Run the code
java -classpath ...:jcov_file_saver.jar ...
• Create a report
java -jar jcov.jar RepGen <jcov xml file> demo
I was able to instrument class files and jar files both, but couldn't run jar one.
Faced this error:
$ java -cp .:$JCOV/jcov_file_saver.jar -jar BubbleSort.jar
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tdk/jcov/runtime/Collect
at BubbleSort.main(BubbleSort.java:49)
Caused by: java.lang.ClassNotFoundException: com.sun.tdk.jcov.runtime.Collect
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
)
Can anyone please help me out or direct me to some web-page where I can understand this?
Using this resolved the issue faced thanks to sumedh's answer which pushed me to understand about various kind of classpaths. Executing instrumented jar: