Unable to start javaagent without errors
I am trying to create a simple Java Agent program before I implement the real thing. I cannot get it to work. Obviously I have some kind of configuration or class issue. No amount of looking and trying led to my problem.
If I run:
java -cp./demoAgent.jar -javaagent: ./ demoAgent.jar com.kingtigerbooks.demoMod.Main
I am getting the following error:
Exception in thread "main" java.lang.ClassNotFoundException: com.kingtigerbooks.demoAgent.Agent
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:280)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:338)
FATAL ERROR in native method: processing of -javaagent failed
Abort trap
I am running this on my Mac. The agent jar file is in the current directory. The manifest for the jar file looks like this:
Manifest-Version: 1.0
Premain-class: com.kingtigerbooks.demoAgent.Agent
Can-Redefine-Classes: true
If it smells like a class problem, but as you can see I have included the jar in the classpath. Any help would be greatly appreciated. This is a very simple project.
+3
source to share