The community will be in read-only from Tuesday 11:59pm (PST) to Wednesday 7:30am (PST)
The community will be in read-only from Tuesday 11:59pm (PST) to Wednesday 7:30am (PST)
Service Desk Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

first web api question

Highlighted
Dantist
Super Collector

first web api question

Hello !
i've try to run my first web api example
and have the problem:

compile the example1.java:
C:\api>javac -classpath "C:\api\web-api.jar" example1.java

BUT it's not start:
C:\api>java -cp "C:\api\web-api.jar;C:\api" example1 sbi MashkovDA MashkovDA
Exception in thread "main" java.lang.NoClassDefFoundError: example1 (wrong name:
com/hp/itsm/api/examples/example1)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)

Whan i must do to resolve it ?
Thanks!
3 REPLIES
Gyula Matics_1
Honored Contributor

Re: first web api question

Remove the package statement from the beginning of the .java source file and use Example1 not example1
Dantist
Super Collector

Re: first web api question

I resolve this problem by remove the package com.hp.itsm.api.examples; line from the Example1.java file

Thank you all !
Dantist
Super Collector

Re: first web api question

i have the second question :)
//Add this to "OnDomLoad" event