Results 1 to 18 of 18
  1. #1
    Mindhunter74 is offline Member
    Join Date
    Dec 2007
    Posts
    9
    Rep Power
    0

    Default Using compiled Classes

    I've got a collection of .class files that I want to use from another class file I'm going to write.

    The problem is that I can't call any of these .class files from the .java file even with putting them all together (the .class files and the new .java file) in a single package in my project.

    How can I resolve this problem?

    Thanks

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    How did you use those class files with your Java files? Can you explain the way you follow bit more.

  3. #3
    AZMichael is offline Member
    Join Date
    Jan 2008
    Posts
    16
    Rep Power
    0

    Default

    Do the classes belong to another package? maybe you need to copy them into the build folder, or import them referencing the package.class name format?

  4. #4
    Mindhunter74 is offline Member
    Join Date
    Dec 2007
    Posts
    9
    Rep Power
    0

    Default

    Quote Originally Posted by AZMichael View Post
    Do the classes belong to another package? maybe you need to copy them into the build folder, or import them referencing the package.class name format?
    That was the problem indeed. Placing them in the default package solved the problem.

    Thank you.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Mindhunter74 View Post
    That was the problem indeed. Placing them in the default package solved the problem.

    Thank you.
    Working with the default package is not safer. Mistakenly it can be refer by other classes. Best thing is import them in the correct/required place.

  6. #6
    Mindhunter74 is offline Member
    Join Date
    Dec 2007
    Posts
    9
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    Working with the default package is not safer. Mistakenly it can be refer by other classes. Best thing is import them in the correct/required place.
    Yes. I believe you are right.

    But what If I do not know the package name where these classes compiled while imported to it?

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Mindhunter74 View Post
    But what If I do not know the package name where these classes compiled while imported to it?
    I'm not clear what you are talking about. When you create a Java class you should know the package name.

  8. #8
    Mindhunter74 is offline Member
    Join Date
    Dec 2007
    Posts
    9
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    I'm not clear what you are talking about. When you create a Java class you should know the package name.
    The fact is that I did not create them.

    Actually I was using a java Neural Networks framework that I have found on the internet provided as a free group of compiled-classes.

    And the author did not mention the package name.

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Mindhunter74 View Post
    And the author did not mention the package name.
    This is bad practice actually.

    You have *.class files, not *.java files right?

  10. #10
    Mindhunter74 is offline Member
    Join Date
    Dec 2007
    Posts
    9
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    This is bad practice actually.

    You have *.class files, not *.java files right?
    Yes! Just the .class files are provided.

    [Edit] If my posts were 20 or more, I would have post you the link of the author's site :)

  11. #11
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Mindhunter74 View Post
    [Edit] If my posts were 20 or more, I would have post you the link of the author's site :)
    Yes, once you reach that mark, send the link here to see.

  12. #12
    Mindhunter74 is offline Member
    Join Date
    Dec 2007
    Posts
    9
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    Yes, once you reach that mark, send the link here to see.
    If you insist to see it now. Please use replaceAll(" +","") and check it :)

    h t t p : / / f b i m . f h - r e g e n s b u r g . d e / % 7 E s a j 3 9 1 2 2 /j f r o e h l / d i p l o m / e - i n d e x . h t m l


    Thanks for your help!

  13. #13
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  14. #14
    AZMichael is offline Member
    Join Date
    Jan 2008
    Posts
    16
    Rep Power
    0

    Default

    I am having a similar problem with jar files as well. I can import OK, and the ide finds the classes, but then won't find them on deployment outside the ide environment.

  15. #15
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  16. #16
    AZMichael is offline Member
    Join Date
    Jan 2008
    Posts
    16
    Rep Power
    0

    Default

    I am now using netbeans 6.1. I was also using JCreatorPro separately, and can go back to it if necessary.

  17. #17
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Once you import all external files into the project and build it, all the files are attach into the src folder. If you are importing jar files, they are attach to the dist/lib folder at project build.

  18. #18
    AZMichael is offline Member
    Join Date
    Jan 2008
    Posts
    16
    Rep Power
    0

    Default

    Yes, that's right. The Jars are attached to the dist/lib folder. As long as I run the application on my own computer, invoking JNLP, no problem. However, the association appears to get lost when I copy the main jar to the server, and place the imported jar files in a /lib directory, then I get a class not found exemption, even though the manifest file shows the /lib/jar files in the class-path. How do I maintain the link so the application can be deployed via JNLP? I've tried every trick I can think of, and have gone over what documentation I could find, and exhausted my options on java tutorials.

Similar Threads

  1. Help with classes
    By gnarly hogie in forum New To Java
    Replies: 14
    Last Post: 10-10-2008, 02:29 PM
  2. Get name of available classes
    By escuja in forum CLDC and MIDP
    Replies: 0
    Last Post: 07-26-2008, 12:03 PM
  3. Cant run my classes
    By Assaf A in forum Eclipse
    Replies: 1
    Last Post: 04-22-2008, 02:31 PM
  4. Help with classes
    By freswood in forum New To Java
    Replies: 5
    Last Post: 04-21-2008, 03:28 PM
  5. When do we use inner classes?
    By cruxblack in forum New To Java
    Replies: 5
    Last Post: 08-10-2007, 05:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •