Path: csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Nigel Wade Newsgroups: comp.lang.java.programmer Subject: Re: Error while compilling program on Linux Date: Tue, 10 May 2011 09:47:59 +0100 Lines: 39 Message-ID: <92sce0FodrU1@mid.individual.net> References: <14db58a7-1f7f-4a8d-89d4-b27559860fff@d1g2000yqm.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: individual.net /UFBmeo5VBQgs+7qSI5W0wLNgeM1qhHbVpFiN7tSjzGMMSWXUO Cancel-Lock: sha1:O9Sn/mLb5MGgYbyDmVhpFs05ziI= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.1.16) Gecko/20101125 SUSE/3.0.11 Thunderbird/3.0.11 In-Reply-To: <14db58a7-1f7f-4a8d-89d4-b27559860fff@d1g2000yqm.googlegroups.com> Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3906 On 10/05/11 06:54, ruds wrote: > Hi, > 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" > I have JDK 1.6 installed and my JAVA_HOME and CLASSPATH variable are > having the paths correct, still I'm getting this error. Neither of those environment variables affect which executable gets run when you type the javac command. > On checking the version: javac -version I'm getting: Eclipse Java > Compiler v_677_R32x, 3.2.1 release > this is happening even if I expicitly set the $CLASSPATH. > I have set CLASSPATH in my .profile too. > This program was working perfectly 10 days ago and now suddenly it has > started giving errors. > What might be the problem? > Please help. Installing Eclipse may have put the Eclipse javac binary before the JDK in the PATH. If so, it's simply a matter of fixing your PATH so that JDK path comes first. You don't say what flavour of Linux you have, but another possible explanation is that it uses "alternatives", and installing Eclipse has overridden the default Java compiler setting. To see if this is the case type (you may need to be root to do this): update-alternatives --list javac If alternatives is installed, and it is being used to provide alternate Java installations, this should tell you which javac are available. You can use the update-alternatives command to switch between the installed Java implementations. -- Nigel Wade