This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Linux / UNIX and the fly likes Linux, JAVA 5 Package importing problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Linux, JAVA 5 Package importing problem" Watch "Linux, JAVA 5 Package importing problem" New topic
Author

Linux, JAVA 5 Package importing problem

Neelesh Sahay
Greenhorn

Joined: Mar 04, 2005
Posts: 3
Hi,
I am new to linux.
I have managed to install the binaries of java 1.5. I have set the classpath and JAVA_HOME(for tomcat). All these things work fine. I have managed to compile simple java files. However when I try to import another package (that I know exists with compiled classes in it) I get

package <package> does not exist
import <pakcage>
^

I have tried this code on another linux machine and it worked fine. So what is wrong with the environment of the machine I am working on. HOw do I get the compiler to import the requirede packages.

Please help
NS
[ March 04, 2005: Message edited by: Ernest Friedman-Hill ]

NS.
Arnaud Burlet
Ranch Hand

Joined: Oct 08, 2004
Posts: 31
A classpath problem maybe ?

try something like
java -cp /path/to/your/package/root:/path/to/your/application application.main_class
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15947
    
  19

import what?

The line as printed isn't a complete Java statement.


Customer surveys are for companies who didn't pay proper attention to begin with.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Originally posted by Tim Holloway:
import what?

The line as printed isn't a complete Java statement.


I edited his message -- HTML is enabled in this forum and he was using "<" and ">" as brackets, so they were invisible.


[Jess in Action][AskingGoodQuestions]
Neelesh Sahay
Greenhorn

Joined: Mar 04, 2005
Posts: 3
by <package> I meant package to be variable my package in this case is called pkg1,
so the error will be:

package temp.Neelesh.pkg1 does not exist
import temp.Neelesh.pkg1.*;
^
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
The problem may be in your CLASSPATH environment variable, it may be helpful if you posted it.
Neelesh Sahay
Greenhorn

Joined: Mar 04, 2005
Posts: 3
$PATH
/usr/local/jdk1.5.0_01/bin:/usr/kerberos/bin:
/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/ssuser/bin

$CLASSPATH

usr/local/jdk1.5.0_01/bin:u01/jfreechart-0.9.15/jfreechart-0.9.15.jar:
/u01/jfreechart-0.9.15/lib/gnujaxp.jar:/u01/jfreechart-0.9.15/lib/jcommon-0.9.0.jar:
/u01/jfreechart-0.9.15/lib/servlet.jar:/u01/jakarta-tomcat-5/common/lib/activation.jar:
u01/axis-1_1/lib/axis.jar:/u01/axis-1_1/lib/axis-ant.jar:/u01/axis-1_1/lib/commons-discovery.jar:
/u01/axis-1_1/lib/commons-logging.jar:/u01/axis-1_1/lib/jaxrpc.jar:/u01/axis-1_1/lib/log4j-1.2.8.jar:
/u01/axis-1_1/lib/saaj.jar:/u01/axis-1_1/lib/wsdl4j.jar:/home /ssuser/com:/home/ssuser/temp/

am I missing something? Note that I can compile a .java file where there are no imports involved. I can also compile files in the same package. I dont understand why I cannot import files
[ March 04, 2005: Message edited by: Ernest Friedman-Hill ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Go and carefully read this. Make sure you're following it properly, especially this part:


If you are trying to locate classes in a directory, then specify the path up to but not including the name of the package the classes are in. (If the classes are in a package called my.package and they are located in a directory called C:\myclasses\here\my\package, you would set the classpath to be CLASSPATH=C:\myclasses\here).
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Where is the source file located?


Java API Documentation
The Java Tutorial
 
Don't get me started about those stupid light bulbs.
 
subject: Linux, JAVA 5 Package importing problem
 
Similar Threads
PropertyNotFoundException
Page Not Found Error w/ JSP
Converting byte array to pdfor any filetype using JSF
Runtime.getRuntime().exec() not working for me at all...
URGENT - Query on wldeploy