java Printstream printf() [message #56360] |
Fri, 22 April 2005 18:25  |
Eclipse User |
|
|
|
Originally posted by: justin.loh.plexelis.com
I have tried to use java printf (available in jdk1.5.0_02) in the
following program:
//Fig 2.6: Welcome4.java
// Printing multiple lines in a dialog box.
public class Welcome4
{
// main method begins execution of Java appliation
public static void main(String args[])
{
System.out.printf("%s\n%s\n", "Welcome to ", "Java
Programming");
} // end method main
} //end class Welcome4
It compile fine when I compile it in cmd window using javac.exe. But when
I tried it in Eclipse, it did not compile giving an exception message:
Exception in thread "main" java.lang.Error: Unresolved compilation
problem:
The method printf(String, Object[]) in the type PrintStream is not
applicable for the arguments (String, String, String)
Can anyone help?
Rgds,
Justin Loh
|
|
|
Re: java Printstream printf() [message #56408 is a reply to message #56360] |
Fri, 22 April 2005 19:10   |
Eclipse User |
|
|
|
Originally posted by: mirdous.seznam.cz
Well try to press ctrl+space to bring content assist
and you'll see there are 2 printf methods
1. printf(Locale, String , Object[])
2. printf(String, Object[])
that's why you get Ex
> Justin Loh wrote:
> I have tried to use java printf (available in jdk1.5.0_02) in the
> following program:
>
> //Fig 2.6: Welcome4.java
> // Printing multiple lines in a dialog box.
>
> public class Welcome4
> {
> // main method begins execution of Java appliation
> public static void main(String args[])
> { System.out.printf("%s\n%s\n", "Welcome to ",
> "Java Programming"); } // end method main
>
> } //end class Welcome4
>
> It compile fine when I compile it in cmd window using javac.exe. But
> when I tried it in Eclipse, it did not compile giving an exception message:
>
> Exception in thread "main" java.lang.Error: Unresolved compilation
> problem: The method printf(String, Object[]) in the type PrintStream
> is not applicable for the arguments (String, String, String)
>
> Can anyone help?
>
> Rgds,
> Justin Loh
>
|
|
|
|
Re: java Printstream printf() [message #57932 is a reply to message #57761] |
Tue, 26 April 2005 17:29  |
Eclipse User |
|
|
|
Originally posted by: wegener.cboenopspam.com
Justin Loh wrote:
> I know about content assist but it does not solve the problem. javac.exe
> compiles OK with the same program but Eclipse just complains with the
> exception message reported. Why??? The same problem is reported by Tim
> Julian:
> 21.04. * System.out.printf Broken? Tim Julian
> 25.04. `* Re: System.out.printf Broken? Chris Laffra
> 26.04. +- Re: System.out.printf Broken? Tim Julian
> 26.04. `- Re: System.out.printf Broken? Tim Julian
> But his case is with:
> System.out.printf( "Product is %dn", result );
> It says .printf is expecting an object[] and not an int!
> Eclipse did not go well with String.format method too and reports the
> similar exception message.
> All I know is that all these two methods are new methods in JDK1.5.0_02
> version and Eclipse just don't how to deal with them (I did set the
> preference>java setting to JRE1.5.0_02).
> Regards,
> Justin Loh
You need to be running one of the 3.1M releases of Eclipse (3.1M6 is
current) and you also need to set you compiler compliance level to 1.5.
|
|
|
Powered by
FUDForum. Page generated in 0.08120 seconds