aspose file tools*
The moose likes Beginning Java and the fly likes Unwanted StringBuilder reference at runtime Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Unwanted StringBuilder reference at runtime" Watch "Unwanted StringBuilder reference at runtime" New topic
Author

Unwanted StringBuilder reference at runtime

Mike Vat
Greenhorn

Joined: Sep 09, 2008
Posts: 10
Hi
I am compiling a java class which does not have any reference to StringBuilder calss. When I compile it is creating StringBuilder reference in .class file. Once I compiled successfully then I ran the java class file then I am getting run time error " java.lang.StringBuilder classdef not found error. Then I search all the files for "StringBuilder" in the file system then it shows the .class file which I compiled. Then I opened the file and be able to see reference for StringBuilder.

My Question: Why it is creating a reference to StringBuilder ? I am using java 1.4 compiler. Also, I have previous version of .class file for this java file . I opened that file but surprisingly that file does not have any reference to StringBuilder. previous version and the version I used for compilation have exactly same source.

Any help will be greatly appreciated.

Thanks
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18846
    
  40

Why it is creating a reference to StringBuilder ? I am using java 1.4 compiler.


Interesting. Can you confirm this by running "javac -J-version"? And while you are at it, can you also run "java -version"?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Mike Vat
Greenhorn

Joined: Sep 09, 2008
Posts: 10
Thanks Henry for your reply.

Ohh I see, some how I am using ver 5 ? Here is my results. What is teh difference between javac -J-version and java -version ?
One is compiler and another is for JAVA ? How can I use 1.4 for both compiling and running ?

Thanks very much for your reply.


java version "1.4.2_12"
=============================
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4
Java HotSpot(TM) Client VM (build 1.4.2_12-b03, mixed mode)


When I say javac -J-version
==============================
java version "1.5.0_11"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode)
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18846
    
  40

How can I use 1.4 for both compiling and running ?


First, you need to confirm that you actually have the java 1.4 compiler installed. If your path points to Java 5 for the compiler and Java 1.4 for the JVM, I am guessing that you don't have the 1.4 JDK installed.

Henry
Mike Vat
Greenhorn

Joined: Sep 09, 2008
Posts: 10
I do have both 1.4 and 1.5. Now I chnaged my PATH setting so that it can look only 1.4. Now it's working. Both java and javac are looking for 1.4.

Thanks veru much for your time. Your comments definitely helped me. thanks very much.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unwanted StringBuilder reference at runtime