Getting error when compiling with printf

I

Ivan

Hi all..

I'm getting an error when trying to compile an adaptation of my
HelloWorld program..

The code looks something like this:

System.out.printf( "%s\n%s\n",
"Hello", "World!" );

I read somewhere that printf is a new feature of J2SE 5.0, so I
reluctenty upgraded from 1.4.2 to 1.5.0, though I'm still getting the
error..

I'll post the error if required, but it's on the other computer..
 
L

Lee Weiner

Hi all..

I'm getting an error when trying to compile an adaptation of my
HelloWorld program..

The code looks something like this:

System.out.printf( "%s\n%s\n",
"Hello", "World!" );

The code works fine for me.

Lee Weiner
lee AT leeweiner DOT org
 
J

James McGill

I'll post the error if required, but it's on the other computer..

It's very poor form to ask for advice on "an error message" without at
least making some attempt to characterize what sort of error message you
mean.
 
O

Owen Jacobson

Hi all..

I'm getting an error when trying to compile an adaptation of my
HelloWorld program..

The code looks something like this:

System.out.printf( "%s\n%s\n",
"Hello", "World!" );

I read somewhere that printf is a new feature of J2SE 5.0, so I
reluctenty upgraded from 1.4.2 to 1.5.0, though I'm still getting the
error..

I'll post the error if required, but it's on the other computer..

It's pretty much required. The posted code, placed in a class's public
static void main (String[]) method, works fine for me.
 
I

Ivan

James said:
It's very poor form to ask for advice on "an error message" without at
least making some attempt to characterize what sort of error message you
mean.

I know.. Was just a bit hard being that it was on my other computer..
But, here it is:

public class Hello
{
public static void main ( String args [] )
{
System.out.printf( "%s\n%s\n,
"Hello", "World!" );
}
}

$ javac Hello.java
Hello.java:5: cannot resolve symbol
symbol : method printf
(java.long.String,java.lang.String,java.lang.String)
location : class java.io.PrintStream
System.out.printf( %s\n%s\n",
^

1 error
 
B

Bart Cremers

Type javac -version to see if you're really using 5.0.

If so, type echo %CLASSPATH% or echo $CLASSPATH to see if you got the
rt.jar of an older jdk in the classpath.

If not, type echo %PATH% or echo $PATH to see where the OS gets the
javac executable.

Bart
 
R

Roedy Green

$ javac Hello.java
Hello.java:5: cannot resolve symbol
symbol : method printf
(java.long.String,java.lang.String,java.lang.String)
location : class java.io.PrintStream
System.out.printf( %s\n%s\n",

One problem is your " don't balance.

that method was just invented with JDK 1.5. Are you using an older
Java?

See http://mindprod.com/jgloss/jdk.html
to upgrade.
 
I

Ivan

Got it working.. Thanks.
I was using 1.4.2 (even though I installed 5.0, I was still using javac
from 1.4.2).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top