wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets 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: 1871
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 A.java in pk1 directory and A class in package pk1.
Now, I have B.java in /usr/home/maulin/java directory and B.java is not in any package.
A.java is as,
package pk1;
import B;
public class A {
public static void main(String[] args) {
B b = new B();
B.java is as,
public class B {

if I remain in /usr/home/maulin/java and try to compile like,
javac pk1/A.java 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: 1871
you can assume I am having current directory in CLASSPATH etc. If I put B.java in package pk2 and create pk2 directory and do 'import pk2.*' in A.java and do things it works....
I agree. Here's the link: http://aspose.com/file-tools
subject: why this doesn't work on java 1.4?
Similar Threads
Help! Difficult in compiling Servlets
How do i compile B.java?
Access modifiers
Package: resolving the class
Package/Classpath problem with 1.4