Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Linux, JAVA 5 Package importing problem  RSS feed

 
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 ]
 
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
 
Bartender
Posts: 19987
95
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.
 
author and iconoclast
Posts: 24203
40
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.*;
^
 
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
Posts: 24203
40
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).

 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is the source file located?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!