This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Linux, JAVA 5 Package importing problem

 
Neelesh Sahay
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Arnaud Burlet
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18272
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import what?

The line as printed isn't a complete Java statement.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Neelesh Sahay
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem may be in your CLASSPATH environment variable, it may be helpful if you posted it.
 
Neelesh Sahay
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
$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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is the source file located?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic