Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Strange exception in Eclipse, but not in CLI
Strange exception in Eclipse, but not in CLI [message #66037] Wed, 18 May 2005 18:58 Go to next message
Eclipse UserFriend
Originally posted by: andrew.fabbro.org

I'm using
* Eclipse 3.0.2
* Windows XPSP2
* Sun 1.5 Update 3 JDK.

Nearly all my attempts to use System.out.printf() throw the same
exception...even when I'm copying examples directly off web sites or
pasting them from the JDK 1.5's docs. The strange thing is that only
Eclipse is throwing these errors, not the underlying javac/java, because
if I compile and run at the command-line outside of Eclipse, the code
works fine.

Code is below. Here is the exception:

Exception in thread "main" java.lang.Error: Unresolved compilation
problems:
The method printf(String, Object[]) in the type PrintStream is not
applicable for the arguments (String, String, String)
The method printf(String, Object[]) in the type PrintStream is not
applicable for the arguments (String, double)
The method printf(String, Object[]) in the type PrintStream is not
applicable for the arguments (String, double, double)
at TestPrintf.main(TestPrintf.java:34)

My first thought was perhaps Eclipse was pointed at the wrong JDK, but
* 1.5 Update 3 is the only JDK on the box
* Eclipse's About says that's the JDK it's using
* All my other 1.5-specific code works fine
* looking at the rt.jar Eclipse attached, it's 1.5

So...I'm confused. Here is the code, which is in a new project all by
itself, with nothing in the build class except the usual run-time:

public class TestPrintf {

public static void main(String[] args) {

String title = "Office Manager";
String name = "David Brent";

/*
* This works
*/

Object[] o = { title, name };
System.out.printf("employee: %s %s\n", o);

/*
* This gives the exception:
*/

System.out.printf("employee: %s %s\n", title, name );

/*
* These are published examples that throws the same exception
*/

double pi = Math.PI;
System.out.printf ("pi = %5.3f%n\n", pi);

System.out.printf ("pi = %5.3f, e = %5.4f %n\n", Math.PI, Math.E);

}

}
Re: Strange exception in Eclipse, but not in CLI [message #66208 is a reply to message #66037] Wed, 18 May 2005 22:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: andrew.fabbro.org

Problem also occurs in 3.1M7.
Re: Strange exception in Eclipse, but not in CLI [message #66595 is a reply to message #66208] Thu, 19 May 2005 13:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wegener.cboenospam.com

You need to use 1.5 language features to call the printf method. Eclipse
3.0.x does not support 1.5 language features. 3.1M7 does. However, you
need to enable 1.5 compiler compliance in the Java->Complier->Compliance
settings for either your workspace or the project
Re: Strange exception in Eclipse, but not in CLI [message #66699 is a reply to message #66595] Thu, 19 May 2005 17:44 Go to previous message
Eclipse UserFriend
Originally posted by: andrew.fabbro.org

Thanks! That nailed it.
Previous Topic:Change from Managed to Standard Make project
Next Topic:WHY ClassNotFoundException?: I had already declared derby plug-in as a dependency/required plug-in
Goto Forum:
  


Current Time: Mon Dec 30 16:51:25 GMT 2024

Powered by FUDForum. Page generated in 0.05786 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top