This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
Here, We have to understand one thing. While we are using objects they are all binded with respect to their package statement.If the objects(Which are said to be in .class files) outside the package also can be accessed by the current class which run by the JVM. So the compiler also not only see the objects in the current directory, but also verifies the loaded class which are required by the program. So, There should be a way to represent the classes which are not presently available in the visibile scope of Java compiler or even to JVM.For that java people provided a feature CLASSPATH. This is the main reason we wanted it.So while operaating with javac the compiler see the claaspath for .class files required for the current running program. This is the main concept.But its very exhastive you have to go for java tutorials to find useful stuff you needed for CLASSPATH and related concepts.
Joined: Feb 27, 2006
Firstly objects comes into picture only @ runtime. Secondly :
Under src directory :
Package temp : Temp.java and B.java Package temp1 : Temp1.java
in order to compile Temp.java we will require Temp1.class file. Right?
2. C:\H(WORK~1\SCJP\SCJP_G~1\src>javac -classpath temp1 temp/Temp.java temp/Temp.java:2: package temp1 does not exist import temp1.Temp1; ^ temp/Temp.java:4: cannot find symbol symbol: class Temp1 class Temp extends Temp1 ^ temp/Temp.java:9: cannot find symbol symbol : variable i location: class temp.Temp System.out.println("Hello World. i=" +i); ^ 3 errors
What is wrong here ?
Joined: Aug 11, 2006
Here a mistake coming at your import statement.otherwise you can even also give full path instead of giving barely as Temp1.
Joined: Aug 11, 2006
Another thing here, your classpath statement erases the ccurrent classpath.So the current directly also you have to give in your classpath. So try this statement