Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes Need to write ArrayList class & Iterator interface in jdk1.1.8 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Need to write ArrayList class & Iterator interface in jdk1.1.8" Watch "Need to write ArrayList class & Iterator interface in jdk1.1.8" New topic
Author

Need to write ArrayList class & Iterator interface in jdk1.1.8

Uma Viswanathan
Ranch Hand

Joined: Jun 14, 2001
Posts: 126
The code had already been written in jdk1.2. Now, we need to code for jdk1.1.8 bcoz HP10.2 supports only java1.
Could someone give me idea to write the ArrayList and Iterator in jdk1.1.8?
Thanx a lot...
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
You could "borrow" the class files from the new JDK and bundle them with your application, if you amend the package import statements.
Otherwise you are just out of luck.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Uma Viswanathan
Ranch Hand

Joined: Jun 14, 2001
Posts: 126
Hi Cindy Glass,
Thanks for the idea...Could you tell me the procedure to borrow the class files?
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
If you open the rt.jar file with WinZip or FileLibrarian or whatever you use, just extract the class files that you want and put them with your class files. Be carefull though, because you need to research to take all the other classes that those 2 rely on to be sure that it works.
Uma Viswanathan
Ranch Hand

Joined: Jun 14, 2001
Posts: 126
Hi Cindy Glass,
Thanx for your reply...
I tried using winzip. It created a zip file. Then if i try to extract that zip file, i could get only rt.jar file.
Could you help me how to extract necessary class files from rt.jar "step by step"? Thank you very much...
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
The jar file IS a zip file already - don't add rt.jar to a new zip file. Instead OPEN the rt.jar using WinZip and it will show you the files that are compressed inside it.
Then extract the classes that you want.
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
You could also download the Collections addin for jdk 1.1 http://java.sun.com/products/javabeans/infobus/#COLLECTIONS
------------------
I Hope This Helps
Carl Trusiak, SCJP2


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Uma Viswanathan
Ranch Hand

Joined: Jun 14, 2001
Posts: 126
Hi Carl Trusiak,
Could you please provide more info (step by step), how the Infobus would help me?
Uma Viswanathan
Ranch Hand

Joined: Jun 14, 2001
Posts: 126
Hi Carl Trusiak,
I had downlaoded collection1_1.zip from the site. Assume proj-name is the folder where all the project related .java files reside. Tried in three ways but all failed...
1) Copied and pasted collections1_1.zip under proj-name folder and set classpath as follows
set CLASSPATH=.;c:\proj-name\collections1_1.zip
This did not work
2) Extracted collections1_1.zip file and then copied and pasted collections.jar file under the folder proj-name. Then set the classpath as
set CLASSPATH=.;c:\proj-name\collections.jar
This also did not work
3) Copied and pasted collections1_1.zip under jdk1.1.8\lib
and set the classpath as
set CLASSPATH=.;c:\jdk1.1.8\lib\collections1_1.zip
This also did not work
Could you help how to use correctly? Thanks a lot...
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
Got to the link provided, read the readme. This is the complete API for Collections as found in jdk 1.2 any code you write in 1.1.8 that uses these calsses should be compatable with jdk 1.2
Uma Viswanathan
Ranch Hand

Joined: Jun 14, 2001
Posts: 126
Gone to the link and read the readme file. That file is asking us to set collections.zip in the classpath...tried but could not succeed. Could you help me how to set the classpath correctly? [assuming that all .java files reside under proj-name folder].
Thanks a lot...
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
I think that the best information available on setting up your java environment is found at Java Tutorial "First Cup of Coffee"
Uma Viswanathan
Ranch Hand

Joined: Jun 14, 2001
Posts: 126
Hi Carl Trusiak,
Thank you very much. I compiled all the programs successfully.
Uma Viswanathan
Ranch Hand

Joined: Jun 14, 2001
Posts: 126
Hi Carl Trusiak,
I tried to execute the program...but i am getting ClassCastException.
Exception in thread "main" java.lang.ClassCastException: java.lang.String
at com.sun.java.util.collections.TreeMap.compare(TreeMap.java:994)
at com.sun.java.util.collections.TreeMap.put(TreeMap.java:444)
at ServerConfigTbl.loadTable(ServerConfigTbl.java:135)
at I2PServer.main(I2PServer.java:190)
In the ServerConfigTbl.java, i tried to call put() of TreeMap class by passing two objects. I am getting the above error.
Could you help me to resolve this? The same code was successfully
compiled and executed in jdk1.2.
After including this collections.zip file, it is successfully compiling in jdk1.1.8 but not executing...Shall we need to do casting? Could you provide me info?
Thank you very much...
Helmut Lerch
Ranch Hand

Joined: Feb 11, 2001
Posts: 48
Hi,
Originally posted by Uma Viswanathan:
I tried to execute the program...but i am getting ClassCastException.
Exception in thread "main" java.lang.ClassCastException: java.lang.String
at com.sun.java.util.collections.TreeMap.compare(TreeMap.java:994)

Take a look at http://java.sun.com/docs/books/tutorial/collections/problems/index.html.
Heli

[This message has been edited by Helmut Lerch (edited October 02, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need to write ArrayList class & Iterator interface in jdk1.1.8
 
Similar Threads
Overriding remove method of an iterator
Enhanced for loop
Display the data in List
which of the two is good practice?
Iterate through fields in an Inner Class