Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error in Package

 
deepak carter
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to do that sir...i am trying since morning
 
Tina Smith
Ranch Hand
Posts: 208
9
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
deepak carter
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody reply in this...???
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PatienceIsAVirtue.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic