• 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

Same java program compiles on only 1 machine.

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a java program that compiles on one UNIX machine but not on another UNIX machine.
Both machines are running java version "1.4.2_07".
When I do a javac -verbose, I can see that they are loading different classes for String.class.
How can I fix this?

$ javac -verbose OracleLoad.java
[parsed OracleLoad.java in 76 ms]
[loaded /usr/java1.2/jre/lib/rt.jar(java/lang/Object.class) in 5 ms]
[checking class OracleLoad]
[loaded /usr/java1.2/jre/lib/rt.jar(java/lang/String.class) in 5 ms]
...
OracleLoad.java:42: Method replaceAll(java.lang.String, java.lang.String) not found in class java.lang.String.
name = name.replaceAll("'",escapeSQL);


On a different UNIX machine
javac -verbose OracleLoad.java
[parsing started OracleLoad.java]
[parsing completed 49ms]
[loading /usr/j2se/jre/lib/rt.jar(java/lang/Object.class)]
[loading /usr/j2se/jre/lib/rt.jar(java/lang/String.class)]
[checking OracleLoad]
^
 
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like the machine that the program is not compiling on is using Java 1.2, the replaceAll() method in String class was introduced in version 1.4.
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
javac -J-version
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the command is "which" in Linux to find out which javac.exe the computer is using. Apparently you have more than one installation of Java on that box. You probably need to change your PATH.
 
Dave Trower
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I figured out the problem, one machine had the wrong version of javac.
The command javac -J-version was used to figure out the problems.
Thanks everyone.
 
reply
    Bookmark Topic Watch Topic
  • New Topic