Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





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.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-10-2007, 11:27 PM
Member
 
Join Date: Nov 2007
Posts: 45
sireesha is on a distinguished road
formatting..
i saw this code in a book.
Code:
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..
Code:
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....
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-10-2007, 11:57 PM
Member
 
Join Date: Aug 2007
Posts: 30
dmacvittie is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-11-2007, 02:41 AM
Member
 
Join Date: Nov 2007
Posts: 45
sireesha is on a distinguished road
Hi,
I installed jdk6 in my pc.
am i using correct version ?
what i have to install ?
please tell me.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 12-11-2007, 03:19 AM
Member
 
Join Date: Nov 2007
Posts: 11
rajiv_bang is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 12-11-2007, 03:42 AM
Senior Member
 
Join Date: Nov 2007
Location: Newport, WA
Posts: 141
staykovmarin is on a distinguished road
Are you sure that you are using java 6? Meaning do you have the right java folder in your PATH?
Do:
Code:
java -version
It tells you the version that you are running.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 12-11-2007, 06:56 PM
Member
 
Join Date: Nov 2007
Posts: 45
sireesha is on a distinguished road
I tried it.Result is
Code:
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 ?
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 12-13-2007, 07:35 PM
Member
 
Join Date: Nov 2007
Posts: 45
sireesha is on a distinguished road
please give me advise
please see previous posts in this thread..give me advise..
thankq verymuch
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 12-31-2007, 05:41 AM
CaptainMorgan's Avatar
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 839
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
sireesha, since you are having problems compiling, post the output of
Code:
javac -version
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.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 01-05-2008, 12:43 AM
Member
 
Join Date: Nov 2007
Posts: 45
sireesha is on a distinguished road
hi
i tried javac -version
but the output is
javac: invalid flag: -version

now what i have to do ?
please tell me,
thankq
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 01-05-2008, 12:45 AM
roots's Avatar
Moderator
 
Join Date: Jan 2008
Location: Dallas
Posts: 260
roots is on a distinguished road
Code:
C:\>javac -version javac 1.6.0_02 C:\>
Strange .. !!
__________________
dont worry newbie, we got you covered.
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 01-07-2008, 08:51 AM
Member
 
Join Date: Jan 2008
Posts: 1
Schmidty is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting a number to currency Java Tip java.text 0 04-16-2008 11:59 PM
Data formatting for the <display:table> yuchuang Web Frameworks 3 12-14-2007 11:52 AM
formatting String bugger New To Java 1 11-16-2007 08:27 PM
Correct Number formatting paul New To Java 1 08-07-2007 05:59 AM
Formatting the date yuchuang New To Java 5 05-07-2007 07:08 PM


All times are GMT +3. The time now is 03:36 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org