• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

J2SDK 1.4.2_11 Won't inherit from other files

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Eric Crockett
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It took out all of my spacing/indenting!

Alas!
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@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?)
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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).
 
Any sufficiently advanced technology will be used as a cat toy. And this tiny ad contains a very small cat:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic