This week's book giveaway is in the Other Open Source APIs forum. We're giving away four copies of Storm Applied and have Sean Allen, Peter Pathirana & Matthew Jankowski on-line! See this thread for details.
Hi All, This is my very first post on this site - I am still getting used to the language and the different design concept, but I like it.
I am using JDK1.5.0_03, installed especially for this exercise, but I also have the previous version, j2sdk1.4.2_07. I have typed in the whole source code, all the classes, etc, but when I tried to compile it, the compiler didn't like the ArrayList<> declaration. I started looking into the API and found that the problem should be somewhere in the Generics area (this was proved when I opened the source in JBuilder). Looked at some tutorials on java.sun and found that all the declarations are correct; then checked out the readme file and found that this is a known problem and the workaround is using -source 1.4 on the javac command line. OK, did that too, same error; deleted both class and path variables related to the 1.4 version, but still didn't work. What am I doing wrong? Thanks in advance. Babi Update: I have used the -source 1.5 switch, that solved that problem now I get 13 errors, all saying "cannot find symbol". All the files are in the same directory and when at command line I am in that directory. Forgot to tell you: I am using XP.
BTW, by browsing previous posts, I've already learned many things. Thanks. [ June 04, 2005: Message edited by: Babi Szolosi ]
Adding generics to ArrayList() is a new feature in the 1.5 SDK; the 1.4 compiler will reject it.
I'd suggest looking at your PATH environment variable and seeing if the 1.4 compiler is being called when you enter 'javac'. If you rearrange your PATH so the 1.5 SDK appears first, the 1.5 compiler will be called first. The alternative is entering the full pathname to the 1.5 compiler (which is more typing than I like, since I'm fairly lazy).
IIRC, Borland's JBuilder still installs a version of the 1.4 SDK and uses that. This is why the book recommends using a text editor over an IDE for learning Java to start with and compiling from the command line, as configuring an IDE can be a little confusing at first. I've been pretty happy with jEdit so far.
If you absolutely have to have an IDE, you may want to look at NetBeans, which plays nice with Java 1.5 and is sponsored by Sun.
Joined: May 25, 2005
Originally posted by Jeremy Clark: IIRC, Borland's JBuilder still installs a version of the 1.4 SDK and uses that.
You are correct, it does. But that can be overridden fairly easily. Install the 1.5 SDK as usual, then go to Tools -> Configure -> JDKs, select Add, then point to the directory the new SDK is installed in. Then go to Project -> Default Project Properties and select the new SDK as the JDK to build with.
(Hrm...maybe this thread should be moved?)
Joined: Jun 03, 2005
Thanks a lot for the advice. Last night I was desperate and did all the things you have suggested (before reading your posts, I am in Melbourne Australia...time difference) and at the end JGrasp helped me out: pointed out the places where I made TYPOS . The best bit is that you proved that I did the right thing and while trying to figure it all out, I've learnt heaps of stuff.