Import your own package
When I import a Java package, I can for example write:
The question is, how would I proceed if I want to import my own package?
I'm using netbeans, and I tried to add a new Library, in tools->libraries, but it doesn't recognize the package it seems.
I tried to copy my jar package to "D:\Program Files (x86)\Java\jdk1.6.0_17\jre\lib" but that didn't seem to help either.
I dont think there is any need to create a library or anything.
In netbeans there is an option to create a package . Right-click on src folder and create one using that and then you can import your package just like you import java packages (java(x). xyx.* or something like that)
I did like he said and set a new Environment Variable CLASSPATH as "E:\NetBeansProjects\Java\Packages". And then I put my package "mypackage" there, but when I try to write: "import mypackage.", nothing pops up, and trying to compile the file gives me error about the package doesn't exist.
Originally Posted by m00nchile
I know, but if I do like that, only one project will be able to import this package. And adding this package to every project I'm going to create seems rather dumb. Then I would add it as a library instead.
Originally Posted by kivohs
Is this package (which was presumably another project) jarred up?
If so, then simply right click on the Libraries bit in the Projects explorer, select add JAR/Folder, and then browse to where your jar file is. No need to mess with the system classpath (not generally a good idea), or stick stuff into the JRE lib (always a bad idea).