printf problem
[nobr]How can i resolve this......it gives me an error that i can't resolver....i'm using netbeans 5
int total = totalRS.getInt( 1 );
// get results
sql ="SELECT surveyoption, votes, id FROM surveyresults " +
"ORDER BY id";
ResultSet resultsRS = statement.executeQuery( sql );
out.println("<title>Thank you!</title>" );
out.println("</head>" );
out.println("<body>" );
out.println("Thank you for participating."
);
out.println("<br />Results:
<pre>" );
// process results
int votes;
while ( resultsRS.next() )
{
out.print( resultsRS.getString( 1 ) );
out.print(": " );
votes = resultsRS.getInt( 2 );
out.printf("%.2f", (double ) votes / total * 100 );
out.print("% responses: " );
out.println( votes );
}// end while
init:
deps-module-jar:
deps-ear-jar:
deps-jar:
Compiling 1 source file to C:\Projects\Java2\WebApplication2\build\web\WEB-INF\classes
C:\Projects\Java2\WebApplication2\src\java\SurveyServlet.java:99: cannot find symbol
symbol : method printf(java.lang.String,double)
location: class java.io.PrintWriter
out.printf( "%.2f", ( double ) votes / total * 100 );
1 error
C:\Projects\Java2\WebApplication2\nbproject\build-impl.xml:319: The following error occurred while executing this line:
C:\Projects\Java2\WebApplication2\nbproject\build-impl.xml:143: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 1 second)[/nobr]
this is what netbeans 5.5 tells me
init:
deps-module-jar:
deps-ear-jar:
deps-jar:
Compiling 1 source file to C:\Projects\Java2\WebApplication2\build\web\WEB-INF\classes
C:\Projects\Java2\WebApplication2\src\java\NewClass.java:23: cannot find symbol
symbol : method printf(java.lang.String,double)
location: class java.io.PrintStream
System.out.printf ("pi = %5.3f%n", pi);
1 error
C:\Projects\Java2\WebApplication2\nbproject\build-impl.xml:319: The following error occurred while executing this line:
C:\Projects\Java2\WebApplication2\nbproject\build-impl.xml:143: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 1 second)
> i swear to god that i've installed java sdk
> 1.5.0_07
> do i need java ee 1.5? is that what u mean?....i
> think i don't need it
> Could it be the ide i'm using Netbeans 5.5.
No swearing needed.
The fact that you have installed it does not mean that you are using it.
I have no idea how netbeans works. But at the very least I would be surprised if it used 1.5 simply because you installed it. You would have to do something to make it aware of 1.5. And there could be something else involved as well.
i think there's something wrong with build-imp.xml
here
<javac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}" deprecation="${javac.deprecation}" source="${javac.source}" target="${javac.target}" includeantruntime="false">
and here
<target name="-do-compile-single" depends="init,deps-jar,-pre-pre-compile">
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
<webproject2:javac>
<customize>
<patternset includes="${javac.includes}"/>
</customize>
</webproject2:javac>
</target>
i tested the printf creating another project in Netbeans and it worked fine...but here in a Web Application it gives those errors