This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Java in General and the fly likes why this doesn't work on java 1.4? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "why this doesn Watch "why this doesn New topic

why this doesn't work on java 1.4?

Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1873
Hi all,
I was using jdk1.2.2 (well might sound too old but thats what it is) on my unix system and my code was compiling okay but when I tried it on java1.4 and faced a problem.
In java1.4 I think- we have to put classes in a package as we can't use classes in the default package in the other classes which are there in some specific packages. e.g.,
if I have a directory
and i'm in /usr/home/maulin/java currently.
I have in pk1 directory and A class in package pk1.
Now, I have in /usr/home/maulin/java directory and is not in any package. is as,
package pk1;
import B;
public class A {
public static void main(String[] args) {
B b = new B();
} is as,
public class B {

if I remain in /usr/home/maulin/java and try to compile like,
javac pk1/ then it complains that it can't find class B.
This is using java1.4 if I use java1.2 then it works. Why they dis-allowed the use of 'default' package (B is in default package - the current directory)?
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1873
you can assume I am having current directory in CLASSPATH etc. If I put in package pk2 and create pk2 directory and do 'import pk2.*' in and do things it works....
I agree. Here's the link:
subject: why this doesn't work on java 1.4?
It's not a secret anymore!