aspose file tools*
The moose likes Beginning Java and the fly likes Importing packages: error again Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Importing packages: error again" Watch "Importing packages: error again" New topic
Author

Importing packages: error again

Rahul Sudip Bose
Ranch Hand

Joined: Jan 21, 2011
Posts: 637

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


SCJP 6. Learning more now.
Sudipta Laha
Ranch Hand

Joined: Aug 23, 2010
Posts: 49
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.


Regards,
Sudipta Kumar Laha
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3553
    
  15
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.


Joanne
prem pillai
Ranch Hand

Joined: Nov 02, 2007
Posts: 87

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

Joined: Jan 21, 2011
Posts: 637

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

Joined: Jan 21, 2011
Posts: 637

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

Joined: Aug 05, 2005
Posts: 3553
    
  15
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Importing packages: error again