Results 1 to 3 of 3
  1. #1
    Bibendum is offline Member
    Join Date
    Oct 2007
    Posts
    7
    Rep Power
    0

    Default Java Package help?

    I just went through the painful process of trying to get a package working for the first time, but I have one last problem.

    I have a package myPackage.geom, with a couple of geometry classes in it.

    It is saved to C:\Users\Joe\java\myClasses\geom\*. I want to get the package to work from another folder, C:\Users\Joe\Java\Puzzle\. However, when I just put import myClasses.geom.*; at the beginning of a file in \Puzzle\, it says that myClasses.geom doesn't exist. How do I get it so that \Puzzle\ can "see" the myClasses package?

  2. #2
    staykovmarin is offline Senior Member
    Join Date
    Nov 2007
    Location
    Newport, WA
    Posts
    141
    Rep Power
    0

    Default

    You need "C:\Users\Joe\java\myClasses\geom\" in your classpath when you run java:
    Java Code:
    java -classpath C:\Users\Joe\java\myClasses\geom\ FileToRun

  3. #3
    Bibendum is offline Member
    Join Date
    Oct 2007
    Posts
    7
    Rep Power
    0

    Default

    I tried that, and now it gives a NoClassDefFoundError whenever I try to run it. This solution seems a little weird, though. If I want to run a file that's just in java\puzzle\, wouldn't setting the classpath to java\myClasses\geom\ make it not even see \puzzle\? How do you set it so that a package is accessible from anywhere else on the computer without having to change the classpath every time? I know it's possible, all of the default Java packages work that way, like java.awt. :confused:

Similar Threads

  1. JXL Package
    By gaya3 in forum Java Servlet
    Replies: 1
    Last Post: 05-23-2008, 10:03 AM
  2. Demonstration of Stack class in java.util package
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-16-2008, 11:33 PM
  3. How to use Stack class in java.util package
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-16-2008, 11:32 PM
  4. java package for ISDN
    By syedumairali in forum Networking
    Replies: 0
    Last Post: 01-20-2008, 09:11 PM
  5. couldn't find the package java.lang
    By katie in forum New To Java
    Replies: 2
    Last Post: 08-04-2007, 06:04 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
  •