Home arrow static arrow Java Programming [Archive] - Package does not exist
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Package does not exist
This topic has 4 replies on 1 page.

Posts:3
Registered: 8/3/04
Package does not exist  
Aug 3, 2004 1:37 AM



 
hi, I am having this problem with package import statements:

I have package "org.opencyc.api" in the following directory
C:\opencyc-0.7.0\src\org\opencyc

and "jug.jar " in the C:\opencyc-0.7.0\src\org\opencyc directory.

The I am importing these two packages as

import org.opencyc.api.*;
import jug.jar.*;

My classpath is as follows:
.;D:\j2sdk1.4.2\jre\lib\rt.jar;D:\j2sdk1.4.2\lib\tools.jar;C:\opencyc-0.7.0\src;C:\opencyc-0.7.0\src\org\opencyc\jug.jar;

and for both the import statements I am getting package does not exist as error.

Can anyone explain to me, what am I doing wrong.

thanks.
 

Posts:12,831
Registered: 2/22/00
Re: Package does not exist  
Aug 3, 2004 2:30 AM (reply 1 of 4)



 
I have package "org.opencyc.api" in the following
directory
C:\opencyc-0.7.0\src\org\opencyc

Eh? What's in the opencyc directory? Is there a subdirectory there called "api" or do you mean something else?

import jug.jar.*;

You don't put jar filenames in import statements. You'd only do an import if the jar holds classes in a package, then you could put the package name in an import statement.
 

Posts:3
Registered: 8/3/04
Re: Package does not exist  
Aug 3, 2004 3:49 AM (reply 2 of 4)



 
yes, api is a subdirectory in the opencyc directory.

I tried with import jug.*;
but it was not working either.

thanks
 

Posts:319
Registered: 11/8/00
Re: Package does not exist  
Aug 3, 2004 3:54 AM (reply 3 of 4)



 
The jug.jar file needs to be in the classpath, is this your problem?

Also you don't import the jar file you import the classes and packages in it. For example if the jug.jar file contains the package org.java.jug and the classes Jug, Mug, Jar you would do
import org.java.jug.*; or  import org.java.jug.Jug;


hope this helps
 

Posts:12,831
Registered: 2/22/00
Re: Package does not exist  
Aug 3, 2004 12:15 PM (reply 4 of 4)



 

I tried with import jug.*;
but it was not working either.

That's because it's also wrong.

Just import the package that's contained in the jar. You don't import the jar file itself.
 
This topic has 4 replies on 1 page.