Kod: Markera allt
public class ChatServer {
public static void main(String[] args) throws Exception {
ServerSocket ss = new ServerSocket(1234);
Socket s = null;
String text = "";
while((s = ss.accept()) != null) {
BufferedReader indata = new BufferedReader(new InputStreamReader(s.getInputStream()));
while((text = indata.readLine()) != null) System.out.println(text);
s.shutdownInput();
}
}
}
Kod: Markera allt
javac ChatServer.java
Kod: Markera allt
java ChatServer
Kod: Markera allt
*@*-ubuntu:~/workspace/chat$ java ChatServer
Exception in thread "main" java.lang.NoClassDefFoundError: ChatServer (wrong name: chat/ChatServer)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: ChatServer. Program will exit.
Lite mer info ifall det behövs:
Kod: Markera allt
*@*-ubuntu:~$ java -version
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot(TM) 64-Bit Server VM (build 17.0-b16, mixed mode)
Kod: Markera allt
*@*-ubuntu:~$ sudo update-alternatives --config java
[sudo] password for *:
There is only one alternative in link group java: /usr/lib/jvm/java-6-sun/jre/bin/java
Nothing to configure.
