aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Client" Watch "Client" New topic
Author

Client

Ritchie Partridge
Greenhorn

Joined: Mar 01, 2004
Posts: 17
Not sure if this the correct forum but i'm trying to write a client which connects to a server and implements an interface ie.formal.one.Connection. The client should send and recieve bytes to request contains of files and directories. The code isn't complete, but the main problem is that when i connect to the server it can't find the correct classes.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

Originally posted by Ritchie Partridge:
the main problem is that when i connect to the server it can't find the correct classes.

Do you mean you get a "ClassNotFound" exception? That's an issue with the Classpath. You need either the directory where the runtime could find the path ie/formal/one/Connection.class or the JAR file where Connection.class is stored in your classpath.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Ritchie Partridge
Greenhorn

Joined: Mar 01, 2004
Posts: 17
I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: ie/formal/part1/Conne
ction (wrong name: Connection)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
3)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at ie.formal.one.Part1Tester.main(Unknown Source)
As far as i can see i have the files in the correct directories, in fact i've put them in the root directory and the ie/formal/one directory
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

Originally posted by Ritchie Partridge:
Exception in thread "main" java.lang.NoClassDefFoundError: ie/formal/part1/Connection (wrong name: Connection)

Does your class Connection above have a "package ie.formal.part1" statement in it? Sounds like the class is being found in the ie/formal/part1 directory, but it's declared to be in the root level package.
Ritchie Partridge
Greenhorn

Joined: Mar 01, 2004
Posts: 17
I have the following two jar files and i HAVE to test them using the following line:
java -cp formal.jar;part2.jar ie.formal.two.Part2Tester <server> <port>
C:\>jar tf formal.jar
META-INF/
META-INF/MANIFEST.MF
ie/
ie/formal/
ie/formal/ca555/
ie/formal/ca555/KeyStore.class
ie/formal/common/
ie/formal/common/Base64Decoder.class
ie/formal/common/Base64Encoder.class
ie/formal/common/CA.class
ie/formal/common/Commands.class
ie/formal/common/Console.class
ie/formal/common/Debug.class
ie/formal/common/Decode.class
ie/formal/common/GetDialog.class
ie/formal/common/NewDialog.class
ie/formal/common/Password$Validate.class
ie/formal/common/Password.class
ie/formal/common/Version.class
ie/formal/common/Warning.class
ie/formal/one/
ie/formal/one/Connection.class
ie/formal/one/Part1Tester.class
ie/formal/two/
ie/formal/two/Connection.class
ie/formal/two/Part2Tester.class
C:\>jar tf part1.jar
META-INF/
META-INF/MANIFEST.MF
Connection/Conn.class
Connection/Connection.class
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

Originally posted by Ritchie Partridge:

C:\>jar tf part1.jar
META-INF/
META-INF/MANIFEST.MF
Connection/Conn.class
Connection/Connection.class

The Connection.class above is the one you posted? Again, you don't have a package statement. First line in the file should be "package Connection".
Ritchie Partridge
Greenhorn

Joined: Mar 01, 2004
Posts: 17
Sorry, i do have that included since, thanks, still doesn't help though, think it's to do with the classpaths when i create the jar file
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Client