Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #3905

Re: Error while compilling program on Linux

Newsgroups comp.lang.java.programmer
From Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at>
Subject Re: Error while compilling program on Linux
References <14db58a7-1f7f-4a8d-89d4-b27559860fff@d1g2000yqm.googlegroups.com>
Message-ID <slrnishsck.phi.avl@gamma.logic.tuwien.ac.at> (permalink)
Date 2011-05-10 08:04 +0000

Show all headers | View raw


ruds <rudranee@gmail.com> 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...

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Error  while compilling program on Linux ruds <rudranee@gmail.com> - 2011-05-09 22:54 -0700
  Re: Error  while compilling program on Linux Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-05-10 08:04 +0000
  Re: Error  while compilling program on Linux Nigel Wade <nmw-news@ion.le.ac.uk> - 2011-05-10 09:47 +0100
  Re: Error  while compilling program on Linux Martin Gregorie <martin@address-in-sig.invalid> - 2011-05-10 20:46 +0000
    Re: Error while compilling program on Linux ruds <rudranee@gmail.com> - 2011-05-10 22:49 -0700
  Re: Error  while compilling program on Linux Roedy Green <see_website@mindprod.com.invalid> - 2011-05-11 03:06 -0700
    Re: Error  while compilling program on Linux Nigel Wade <nmw-news@ion.le.ac.uk> - 2011-05-11 14:47 +0100
      Re: Error  while compilling program on Linux Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-05-11 15:31 +0000
        Re: Error  while compilling program on Linux Lew <noone@lewscanon.com> - 2011-05-11 16:01 -0400

csiph-web