|
|
Welcome to the Java Forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:
- have access to post topics
- communicate privately with other members (PM)
- not see advertisements between posts
- have the possibility to earn one of our surprises if you are an active member
- access many other special features that will be introduced later.
Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact us.
|
|

12-10-2007, 11:27 PM
|
|
Member
|
|
Join Date: Nov 2007
Posts: 45
|
|
|
formatting..
i saw this code in a book.
import java.util.*;
public class test4
{
public static void main(String args[])
{
Calendar c=Calendar.getInstance();
System.out.format("%tB %td,%tY%n",c,c,c);
System.out.format("%tl:%tM %tp%n",c,c,c);
System.out.format("%tD%n",c);
}
}
but when i compile this i got some errors.
like..
test4.java:12: cannot resolve symbol
symbol : method format (java.lang.String,java.util.Calendar,java.util.Calendar,
java.util.Calendar)
location: class java.io.PrintStream
System.out.format("%tB %td,%tY%n",c,c,c);
^
test4.java:13: cannot resolve symbol
symbol : method format (java.lang.String,java.util.Calendar,java.util.Calendar,
java.util.Calendar)
location: class java.io.PrintStream
System.out.format("%tl:%tM %tp%n",c,c,c);
^
test4.java:14: cannot resolve symbol
symbol : method format (java.lang.String,java.util.Calendar)
location: class java.io.PrintStream
System.out.format("%tD%n",c);
^
3 errors
what is wrong with this code ?
is it necessary to import any other packages ?
please tell me....
|
|

12-10-2007, 11:57 PM
|
|
Member
|
|
Join Date: Aug 2007
Posts: 30
|
|
|
Hello sireesha,
You are probably using an older version of Java. Format is a relatively recent addition to PrintStream. (meaning a recent addition to System.out)
Don.
__________________
Don MacVittie F5 Networks - To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

12-11-2007, 02:41 AM
|
|
Member
|
|
Join Date: Nov 2007
Posts: 45
|
|
|
Hi,
I installed jdk6 in my pc.
am i using correct version ?
what i have to install ?
please tell me.
|
|

12-11-2007, 03:19 AM
|
|
Member
|
|
Join Date: Nov 2007
Posts: 11
|
|
|
Hi Sireesha,
System.out.format was introduced in J2SE 5.0. If you have a jdk later than that, it should work.
If you are facing problems, try replacing the format with printf. For most practical purposes System.out.format and System.out.printf are the same.
HTH
Rajiv
|
|

12-11-2007, 03:42 AM
|
|
Senior Member
|
|
Join Date: Nov 2007
Location: Newport, WA
Posts: 141
|
|
Are you sure that you are using java 6? Meaning do you have the right java folder in your PATH?
Do:
It tells you the version that you are running.
|
|

12-11-2007, 06:56 PM
|
|
Member
|
|
Join Date: Nov 2007
Posts: 45
|
|
I tried it.Result is
E:\WINDOWS\java>java -version
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode)
now what i have to do.
is this the correct version ?
|
|

12-13-2007, 07:35 PM
|
|
Member
|
|
Join Date: Nov 2007
Posts: 45
|
|
|
please give me advise
please see previous posts in this thread..give me advise..
thankq verymuch
|
|

12-31-2007, 05:41 AM
|
 |
Moderator
|
|
Join Date: Dec 2007
Location: NewEngland, US
Posts: 839
|
|
sireesha, since you are having problems compiling, post the output of
which is different from above. java is the command for running the application while javac is used for compiling your classes. By default, some systems (like my Ubuntu system), contains symlinks to the 1.4 version for the javac command, which obviously can present problems. If this is the case for you, you would simply need to make the link for the javac command to your more updated jvm, in your case 1.6.
|
|

01-05-2008, 12:43 AM
|
|
Member
|
|
Join Date: Nov 2007
Posts: 45
|
|
|
hi
i tried javac -version
but the output is
javac: invalid flag: -version
now what i have to do ?
please tell me,
thankq
|
|

01-05-2008, 12:45 AM
|
 |
Moderator
|
|
Join Date: Jan 2008
Location: Dallas
Posts: 260
|
|
C:\>javac -version
javac 1.6.0_02
C:\>
Strange .. !!
__________________
dont worry newbie, we got you covered.
|
|

01-07-2008, 08:51 AM
|
|
Member
|
|
Join Date: Jan 2008
Posts: 1
|
|
|
Javac link bad in Ubuntu Linux
All Ubuntu users who upgrade to Java 6 need to check their javac compiler link as it is still pointing to the Java 1.4 if they didn't install the Java source. I noticed this when I did a check on my system and was having a problem compiling a 'System.out.format()' and couldn't figure out why I was getting the following error;
Format.java:33: cannot resolve symbol
symbol : method format (java.lang.String,java.util.Calendar)
location: class java.io.PrintStream
System.out.format("Local time: %tT", Calendar.getInstance());
Check your links in Ubuntu;
schmidty@laptop:~/java_work$ ls -alh /etc/alternatives/javac
lrwxrwxrwx 1 root root 27 2007-12-20 18:17 /etc/alternatives/javac -> /usr/lib/j2se/1.4/bin/javac
schmidty@laptop:~/java_work$ ls -alh /etc/alternatives/java
lrwxrwxrwx 1 root root 36 2007-12-20 18:22 /etc/alternatives/java -> /usr/lib/jvm/java-6-sun/jre/bin/java
schmidty@laptop:~/java_work$ ls -alh /etc/alternatives/javac
lrwxrwxrwx 1 root root 33 2008-01-06 22:42 /etc/alternatives/javac -> /usr/lib/jvm/java-6-sun/bin/javac
schmidty@laptop:~/java_work$ ls -alh /etc/alternatives/java
lrwxrwxrwx 1 root root 36 2007-12-20 18:22 /etc/alternatives/java -> /usr/lib/jvm/java-6-sun/jre/bin/java
Again, the solution would be to install the source for Java6 in Ubuntu.
Schmidty
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|