Path: csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!texta.sil.at!newscore.univie.ac.at!aconews-feed.univie.ac.at!aconews.univie.ac.at!not-for-mail Newsgroups: comp.lang.java.programmer From: Andreas Leitgeb Subject: Re: Error while compilling program on Linux References: <14db58a7-1f7f-4a8d-89d4-b27559860fff@d1g2000yqm.googlegroups.com> Reply-To: avl@logic.at User-Agent: slrn/pre0.9.9-111 (Linux) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: Date: 10 May 2011 08:04:36 GMT Lines: 41 NNTP-Posting-Host: gamma.logic.tuwien.ac.at X-Trace: 1305014676 tunews.univie.ac.at 60386 128.130.175.3 X-Complaints-To: abuse@tuwien.ac.at Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3905 ruds wrote: > I want to execute a program on linux but it is giving me an error: > "Syntax error, 'for each' statements are only available if source > level is 5.0" Something seems to be telling your compiler to expect some older source. > I have JDK 1.6 installed and my JAVA_HOME and CLASSPATH variable are > having the paths correct, still I'm getting this error. > On checking the version: javac -version I'm getting: Eclipse Java > Compiler v_677_R32x, 3.2.1 release If you have the "JDK 1.6" installed, I'd expect "javac" to be the jdk's javac, not eclipse's. At command line (assuming bash - start one, otherwise), enter type -all javac and see, which paths all contain a javac, and which of them is first one. If you see some common path, like /usr/bin/javac, then also do an "ls -l /usr/bin/javac" to see, if it happens to be some symlink to somewhere else. Of course, there's also the question, of what *seemingly irrelevant* (you surely have thought about the others, already) changes you have done to the system *before* you first noticed the error. Even with eclipse's javac, you could try explicit -source 5 option to see if that would override any other defaults. But more likely, some change caused a reordering of the javac's found on your system. > this is happening even if I expicitly set the $CLASSPATH. > I have set CLASSPATH in my .profile too. You shouldn't do that. I'm counting on Lew & others to explain better, in how far this is really a bad idea...