M
M
Mr_Virtus2014-04-23 09:56:21
Java
Mr_Virtus, 2014-04-23 09:56:21

NanoHTTP web server

Hello. Downloaded from
https://github.com/NanoHttpd/nanohttpd
web server.
Now I want to compile and run it.
The file is compiled javac NanoHTTPD.java //ok
And then I want to run it:
java NanoHTTPD 8080
and I get an error:

Exception in thread "main" java.lang.NoClassDefFoundError: NanoHTTPD (wrong name
: fi/iki/elonen/NanoHTTPD)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java: 792)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
2)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java. lang.ClassLoader.loadClass(ClassLoader.java:357)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)

Why is this happening, how to solve?
Thanks

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Moseychuk, 2014-04-23
@Mr_Virtus

Because the class must be referred to by its fully qualified name, including the package.
java fi.iki.elonen.NanoHTTPD 8080

M
Mr_Virtus, 2014-04-23
@Mr_Virtus

Thank you.
Now writes:
Error: Could not find or load main class fi.iki.elonen.NanoHTTPD

M
Mr_Virtus, 2014-04-23
@Mr_Virtus

Understood, in this file an abstract class.
The server itself is in the file SimpleWebServer

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question