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?
You need "C:\Users\Joe\java\myClasses\geom\" in your classpath when you run java:
java -classpath C:\Users\Joe\java\myClasses\geom\ FileToRun
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: