Click to See Complete Forum and Search --> : DRIVING ME INSANE -- indentical Java class compiles on one system, but not another
Ethan
06-13-2001, 05:53 PM
I'm using one Mandrake system for development, and another to deploy applications. I recently reinstalled Linux on my development machine and since then everything has been screwy.
I have a Java class that uses the java.lang.String.substring(int*beginIndex, int*endIndex) method. When I try to complile it on the development system I get:
ArticleManager.java:248: Can''t find method "substring(int, int)"
However, if I ftp it over to the deployment server, it compiles.
Any idea how I can get it to compile on the development machine?
Thanks.
- e
Dru Lee Parsec
06-13-2001, 06:17 PM
Can you show the actual line of code where you're using it? That certainly doesn't make sense that it compiles in one place and not the other. Very odd.
Ethan
06-13-2001, 07:34 PM
I made a mistake in describing the problem: it's java.lang.Stringbuffer.substring(int*start, int*end), not String.
Anyway, here is the entire method that contains the line that calls substring(int,int):
// Does a search and replace operation on a String
public String repl( String inputText, String replaceThis, String replaceWith )
{
StringBuffer buff = new StringBuffer( inputText );
for ( int i = 0 ; i < (buff.length() - replaceThis.length()) ; )
{
String s = buff.substring( i , i + replaceThis.length() );
if ( s.equalsIgnoreCase( replaceThis ) )
{
buff = buff.replace( i , i + replaceThis.length() , replaceWith );
i+=replaceWith.length();
}
else
{
i++;
}
}
return buff.toString();
}
Thanks.
- e
Originally posted by Dru Lee Parsec:
<STRONG>Can you show the actual line of code where you're using it? That certainly doesn't make sense that it compiles in one place and not the other. Very odd.</STRONG>
Correct me if I'm wrong, but don't many linux systems ship with kaffe, which is not 100% compatible with Sun's jdk? IIRC, I remember reading somewhere that kaffe was "lagging behind".
Ethan run 'javac -v' or --version or something to see what version of java you're running, on each machine. (Obviously, they must be different. If you're not adamant about using free (as in speech) software, I would think you could switch from kaffe (which I bet is what your linbox is using) to sun's jdk. (or maybe you can just update kaffe.
According to the Java 2 Platform API specs, what you're doing is fine.
Ethan
06-14-2001, 07:01 PM
I did as you suggested. On the machine with the problems, javac -v returns
KOPI Java Compiler Version: 1.3C
so I guess you're right. Evidentally, when I reinstalled Linux from the Mandrake CDs, somehow Kaffe became the Java compiler. I would be happy to switch to Sun's JDK. How do I control which compiler is used when I type "javac"?
Thanks.
Ethan
Well, if you install Sun's version to the same directory, it would overwrite kaffe (which you may not want to do until you're sure you've got it set right), so you could install that to /usr/local/bin (which probably comes later in the path, so will not be executed since the kaffe version will be seen first). Then just rename the kaffi javac to javac.kaffe or javac.old or something, so you won't do any real harm to it, but you'll make sure it doesn't get executed when you type javac.
Dru Lee Parsec
06-17-2001, 02:19 PM
Also, Mandrake puts the Kaffe JDK directly into the /usr/local directory WHICH SUCKS!
It should be somewhere like /usr/local/java/jdk1.3 or something that makes sense. NEVER put an entire product and all it's support files into a generic directory.
So, I bet it's a version issue. Get rid of the Kaffe jdk by at least deleting the java and javac files. Install the Sun JDK for Linux in a reasonable directory and set your path to include the JDK1.3/bin directory.
Good luck
Ethan
06-17-2001, 04:06 PM
It turns out that the compiler version theory of why the class won't compile is incorrect. I used KDE's graphical package manager to uninstall Kaffe, leaving Sun's JDK 1.3 as the only java compiler on the machine, and I'm still getting the same error message as before.
(By the way, I put JDK 1.3 in /usr/local/JDK1.3/. I hope that's a good place to have it.)
Anyway, for some reason, the compiler can't find this basic utility class that comes with Java. Is there any other possible expanation? Is it possible that when I ran the Mandrake installer a couple weeks ago in order to add a piece of software, it screwed up some config file? Are there any config files that are particularly likely to be the problem?
Maybe I'll try deleting JDK 1.3 and re-installing it.
- E