GeeCON Prague 2014*
The moose likes Java in General and the fly likes J2SDK 1.4.2_11 Won't inherit from other files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "J2SDK 1.4.2_11 Won Watch "J2SDK 1.4.2_11 Won New topic
Author

J2SDK 1.4.2_11 Won't inherit from other files

Eric Crockett
Greenhorn

Joined: Jan 24, 2005
Posts: 25
When I upgraded from j2sdk 10 to version 11, all of my programs which accessed a public class in another file in the same folder stopped working. When compiling the main file, I get a compile time error saying "variable not found" followed by the public class in the other file. In order to get my programs to work, I have to copy all of the code, minus the public keyword, into the main file, defeating the purpose of having multiple files.

Not easily discouraged, I tried again on another computer. In fact, I tried on no less than 6 computers with varying degrees of success and failure.

2 or 3 did the same thing as my own, I got a compile time error.

2 or 3 others compiled fine, but when I went to run the program, I got a run time error saying no class path def found, even though I had successfully compiled and a class file was physically in the folder.

And then the freaky one. One computer worked. Flawlessly.

Did something about inheritance change in J2SDK 1.4.2_11? Am I doing something wrong? I installed all of these in the same way on all of the computers.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8915
    
    8

I don't see anything like that in the 1.4.2 release notes. You don't mention what JDK/JRE versions the other computers are running. These symptoms could be caused by something as simple as the CLASSPATH being different between the computers. Did you compare environments? Can you give us a very small example of code (i.e. two bare classes in seperate files) which exhibits these symptoms?


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Eric Crockett
Greenhorn

Joined: Jan 24, 2005
Posts: 25
All of the other computer were using 1.4.2_11 also, that is why I had this problem in the first place. As an example

//File "Test.java"
public class Test {
public static void print() {
System.out.println("Hi!");
}
}
//End file "Test.java"


//File "Driver.java"
class Driver { //could be public, doesn't have to be
public static void main(String args[]) {
Test.print();
}
}
//End file "Driver.java"



Unless I have made a simple mistake, this should compile and run fine. These two files would be located in the same folder.

Thanks for your [very] quick reply!
Eric Crockett
Greenhorn

Joined: Jan 24, 2005
Posts: 25
It took out all of my spacing/indenting!

Alas!
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8915
    
    8

Use Code Tags to preserve your formatting.
I compiled your code under 1.4.2_08 and 1.4.2_11 and saw no difference:




So there doesn't appear to be any difference between these versions. Are you certain you are compiling under the same version of Java (run "java -version")? Are you certain the environments of the systems are identical (check PATH and CLASSPATH). Are you sure you are running with current class files? Blank out the CLASSPATH and erase all existing class files to make sure.
[ April 14, 2006: Message edited by: Joe Ess ]
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

@joe: Why should he compile the classes under the same version?
The given classes should compile as well with a JDK-1.1 - compiler.

When I take two classes:

and compile both with 1.4 - then compile only the 1.5-Version, the Version1_4.class is found, and nothing is recompiled.
Running classes of different compile-versions has never been a problem for me (how would I handle foreign jar-files else?)


http://home.arcor.de/hirnstrom/bewerbung
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8915
    
    8

Originally posted by Stefan Wagner:
. . .and nothing is recompiled.


That's why I told him to blank out the classpath and erase existing class files. Eric thinks something changed between JDK versions AND he's seeing different behavior on different computers. I don't see any difference between JDK versions, and there's nothing unusual in the code. I think he's got environment issues (i.e. bad class in the classpath).
 
GeeCON Prague 2014
 
subject: J2SDK 1.4.2_11 Won't inherit from other files