Results 1 to 5 of 5
Thread: Cannot run on server
- 01-15-2012, 02:44 PM #1
Member
- Join Date
- May 2011
- Posts
- 84
- Rep Power
- 0
Cannot run on server
Hi,
I am trying to do a basic networking. Both client and server programs work when I run them in IDE on my local machine. However, when I upload my server code (NetworkingServer.class) to the server (Debian with openjdk) and try to run it with "java NetworkingServer" I get these errors:
The code:Java Code:Exception in thread "main" java.lang.NoClassDefFoundError: NetworkingServer (wrong name: networkingserver/NetworkingServer) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:634) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:277) at java.net.URLClassLoader.access$000(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:212) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334) Could not find the main class: NetworkingServer. Program will exit.
Java Code:package networkingserver; import java.net.*; import java.io.*; public class NetworkingServer { public static void main(String[] args) throws IOException { ServerSocket serverSocket = null; Socket clientSocket = null; try { serverSocket = new ServerSocket(4444); } catch (IOException e) { System.err.println("Could not listen on port: 4444"); System.exit(1); } try { clientSocket = serverSocket.accept(); } catch (IOException e) { System.err.println("Accept failed."); System.exit(1); } clientSocket.close(); serverSocket.close(); } }
- 01-15-2012, 03:21 PM #2
Re: Cannot run on server
The class is in a package: networkingserver. Wherever you specify the class name you need to include the package in the name.java.lang.NoClassDefFoundError: NetworkingServer (wrong name: networkingserver/NetworkingServer)
Or remove the class from the package.
- 01-15-2012, 03:29 PM #3
Member
- Join Date
- May 2011
- Posts
- 84
- Rep Power
- 0
Re: Cannot run on server
What do you mean, exactly?Wherever you specify the class name you need to include the package in the name.
- 01-15-2012, 03:33 PM #4
Re: Cannot run on server
I don't know how you configure the server. If there is a place for you to enter a class name, use the full class name that includes the package:
For example: classname=thepackage.TheClass
There is some code trying to load your class that only uses: TheClass, it should use thepackage.TheClass
That is what the error message is saying. It read the class file and found the classname included a packagename but that packagename was not included.
Sometimes it is simpler to remove the package statement from your source.
- 01-15-2012, 03:38 PM #5
Member
- Join Date
- May 2011
- Posts
- 84
- Rep Power
- 0
Similar Threads
-
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorre
By nandhinianand in forum New To JavaReplies: 6Last Post: 12-25-2011, 11:33 PM -
from local server to remote server
By IDH in forum Java ServletReplies: 1Last Post: 03-24-2011, 09:05 AM -
Ping a server when server is not in the localhost..
By kshitiz in forum New To JavaReplies: 1Last Post: 03-19-2009, 09:17 PM -
smtp server configuration with jboss server
By vilas_patil in forum Java ServletReplies: 0Last Post: 01-05-2009, 01:18 PM -
Does any file in an FTP server ends up in an HTTP server?
By islamfunny in forum CLDC and MIDPReplies: 4Last Post: 08-15-2008, 04:30 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks