• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Client

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ritchie Partridge
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Let's get him boys! We'll make him read this tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic