using import  
Author Message
Martin Cranna





PostPosted: 2006-1-28 21:32:00 Top

java-programmer, using import I'm trying to import the Welomb class in the java divelog tutorial into
another application. But when I type import divelog.* it refuses

the absolute path for Welcome is
d:\Documents\Java\Divelog\src\divelog

the application I'm trying to import it from is at

d:\Documents\Java\Frames\src\frames

I've also tried creating a library (MyLibrary) and pointing to the
divelog.jar file and setting the classpath to point at divelog.jar. I've
then added the library to my project but when I try and create a Welcome
class it says it cant find the class. So neither using a library or
importing work.

I'm using sun java studio enterprise8 (free) does anyone know how to import
the divelog package into my app using an import statement.

I've tried the following with no success

import divelog.*
import Documents.Java.Divelog.src.divelog.*
in both cases I get package diesnt exist

any suggestion welcome!!



 
Roedy Green





PostPosted: 2006-1-28 22:10:00 Top

java-programmer >> using import On Sat, 28 Jan 2006 13:32:28 -0000, "Martin Cranna"
<email***@***.com> wrote, quoted or indirectly quoted
someone who said :

>the application I'm trying to import it from is at
>
>d:\Documents\Java\Frames\src\frames

imports have nothing to do with where the files are, but what their
packages are called. The classpath deals with where they are.

see http://mindprod.com/jgloss/import.html
http://mindprod.com/jgloss/package.html
http://mindprod.com/jgloss/classpath.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Martin Cranna





PostPosted: 2006-1-29 5:19:00 Top

java-programmer >> using import Any idea how I tell sun's java studio enterprise to amend its classpath?.
I've tried adding a new library and giving it a valid classpath that way and
it doesnt work? At this rate I'm going to have to switch to just using an
editor and the basic sdk in preference to the $2000 IDE.



 
 
Martin Cranna





PostPosted: 2006-1-29 5:39:00 Top

java-programmer >> using import In case anyone else has this problem I've found a solution. Firstly you use
import divelog.* in your source. As mentioned earlier this causes a no such
package error. Dont create a libary out of divelog and add the library to
your project, this doesnt work. Though I dont see why.

Do this instead

right click on the project.
Select properties.
Select Libraries. (whatever you do dont select sources)
Select Add Jar file.
Browse to your jar file (in this case divelog.jar) close everything and the
ide should now find the divelog package.


Is their a help group specifically about using various IDE's ?
Thanks to Roedy Green for putting me straight about imports. Because of the
way my IDE combines Application name and package name to produce a unique
path I thought the import statment must in some way also reflect the hard
disk path.