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 Beginning Java and the fly likes Error in Package 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 » Java » Beginning Java
Bookmark "Error in Package" Watch "Error in Package" New topic
Author

Error in Package

deepak carter
Ranch Hand

Joined: Feb 19, 2011
Posts: 165
Hi,

I have following directory structure

F:\java1\new1\Test.java

The code for Test.java is



the second directory structure is

F:\java2\new2\Test2.java

which has the following code


I am compiling the Test.java in the following way

F:\>javac java1\new1\Test.java

and its compiling fine


when i am trying to compile Test2.java which is in java2\new2 package

F:\java2>set classpath.;= f:\java1\new1\Test.java

F:\java2>javac new2\Test2.java

Its showing error message



import java1.new1.*;
^
Test2.java:8: error: cannot find symbol
Test test=new Test();
^
symbol: class Test
location: class Test2
Test2.java:8: error: cannot find symbol
Test test=new Test();
^
symbol: class Test
location: class Test2
3 errors



James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1012
    
    5

The compiler cannot find Test.class which was generated when you successfully compiled Test.java.

Ensure Test.class is on your class path when you compile Test2.java
deepak carter
Ranch Hand

Joined: Feb 19, 2011
Posts: 165
how to do that sir...i am trying since morning
Tina Smith
Ranch Hand

Joined: Jul 21, 2011
Posts: 171
    
    5

Put Test.class on your classpath...not Test.java. Or just put the whole new1 directory on the classpath.

It's also a good idea to specify the classpath right in the javac command rather than setting the environment variable.


Everything is theoretically impossible, until it is done. ~Robert A. Heinlein
deepak carter
Ranch Hand

Joined: Feb 19, 2011
Posts: 165
javac -cp .;C:\Tomcat 6.0\webapps\Beer-v1\WEB-INF\classes PropertyExample.java

I am using above path to compile but showing the error



C:\>javac -cp .;"c:\Tomcat 6.0\webapps\jsp\WEB-INF\classes" PropertyExample.java

javac: file not found: PropertyExample.java
Usage: javac <options> <source files>
use -help for a list of possible options
deepak carter
Ranch Hand

Joined: Feb 19, 2011
Posts: 165
Can anybody reply in this...???
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

PatienceIsAVirtue.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
wood burning stoves
 
subject: Error in Package
 
Similar Threads
Regarding Package
cannot find symbol - compiler error?
doubt related to packages (To chandilya poppuru)
class in the default package not found by javac?
Error: Cannot find symbol during Importing package