• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Importing packages: error again

 
Ranch Hand
Posts: 637
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am compiling my programs using ONLY the console. I get an error which i will show below. The following is my directory structure :
floor1 is a folder. floor2 and floor3 are packages.The rest are classes.


Now the source code for all the classes :


The above class compiles successfully with path as shown below :
C:\rb\floor1>javac Class1.java
C:\rb\floor1>


error !

The above class FAILS to compile WHEN i go to its folder and try to compile !. Here is the error :
C:\rb\floor1\floor2>javac Class2.java
Class2.java:2: package floor2.floor3 does not exist
import floor2.floor3.*;
^
1 error
C:\rb\floor1\floor2>


The above class compiles successfully with path as shown below :
C:\rb\floor1\floor2\floor3>javac Class3.java
C:\rb\floor1\floor2\floor3>


PS : I have tried to make it as easy as possible to review my code. Please let me know if its too verbose or if it could be improved.
regards rb
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The class you are compiling has an import statement floor2.floor3.*, but you are compiling inside the floor2 folder. So its giving error. Please modify your import statement and try to compile.
 
Rancher
Posts: 3742
16
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The import statements are fine. Tha problem is the same as in your other post. You need to include the C:\rb\floor1 directory in your classpath. This is why you should specify the classpath on the command line and not in the CLASSPATH environment variable. It's going to be different for each of your projects.
 
Ranch Hand
Posts: 87
Opera Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rahul Sudip Bose wrote:


Even if not directly related to this subject; You can create such char representations using Tree command. In windows you just type "tree /F"


 
Rahul Sudip Bose
Ranch Hand
Posts: 637
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

prem pillai wrote:

Rahul Sudip Bose wrote:
Even if not directly related to this subject; You can create such char representations using Tree command. In windows you just type "tree /F"



Thanks, you lifted a major burden off me ! God, do i need to learn DOS also ? can you suggest a good book/website to learn such stuff ?

 
Rahul Sudip Bose
Ranch Hand
Posts: 637
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joanne Neal wrote:The import statements are fine. Tha problem is the same as in your other post. You need to include the C:\rb\floor1 directory in your classpath. This is why you should specify the classpath on the command line and not in the CLASSPATH environment variable. It's going to be different for each of your projects.



If its already set in environment variables, can i reset it temporarily in CMD ? or i have to delete the variable ?
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rahul Sudip Bose wrote:If its already set in environment variables, can i reset it temporarily in CMD ? or i have to delete the variable ?

Yes. If you use the -cp command line option the CLASSPATH environment variable will be ignored.
reply
    Bookmark Topic Watch Topic
  • New Topic