absolute newbie question

Folks,

I'm talking a java class in my "spare time" and just getting started this week.

I'm also very new to linux so it makes things tricky for me figuring out where my problems are.

I'm copying code out of Deitel just to try to get something to compile...

one class is as follows:

// Fig. 3.11: GradeBookTest.java

// GradeBook constructor use to specify the course name at the

// time each GradeBook object is created.

public class GradeBookTest

{

// main method begins program execution

public static void main( String args[] )

{

// create GradeBook object

GradeBook gradeBook1 = new GradeBook(

"CS101 Introduction to Java Programming" );

GradeBook gradeBook2 = new GradeBook(

"CS102 Data Structures in Java" );

// display initial value of courseName for each GradeBook

System.out.printf( "gradeBook1 course name is: %s\n",

gradeBook1.getCourseName() );

System.out.printf( "gradeBook2 course name is: %s\n",

gradeBook2.getCourseName() );

} // end main

} //end class GradeBookTest

This code, and the GradeBook class it is supposed to test, both compile fine, but when I go to run it I get an error:

Exception in thread "main" java.lang.NoSuchMethodError: method java.io.PrintStream.printf with signature (Ljava.lang.String;[Ljava.lang.Object;)Ljava.io.PrintStream; was not found.

at GradeBookTest.main(java.lang.String[]) (Unknown Source)

at gnu.java.lang.MainThread.call_main() (/usr/lib/libgcj.so.6.0.0)

at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0)

This seems like a linking type of problem to me, but I'm not really comfortable enough with java or linux to figure out what my problem is.

Do I need to set up some type of config file so java knows where to find the printf method or something?

Thanks a lot in advance if you have an idea

Ben

[1970 byte] By [benva] at [2007-10-2 12:04:08]
# 1
Check what version of java you are using via the command: java -versionThe printf() methods were added in java 1.5. If you are using a previous version, the method won't exist and you would get the message you are getting.
Gita_Weinera at 2007-7-13 8:26:54 > top of Java-index,Java Essentials,New To Java...
# 2
wow, that was fast, and correct!it said 1.4.2.i did, or thought i did, just use synaptic to get 1.5. i'll have to figure out how to get that version in my path before the 1.4.2?
benva at 2007-7-13 8:26:54 > top of Java-index,Java Essentials,New To Java...
# 3
it looks like what is in my /bin folder is a link to an executable. i'll dig through my linux book, but do you know offhand how i would go about updating that to point to the right version?thanks again, or for the first time since i forgot to say it before!Ben
benva at 2007-7-13 8:26:54 > top of Java-index,Java Essentials,New To Java...
# 4
ha, got it!/usr/bin$ sudo ln -s -f -v /usr/java/jre1.5.0_02/bin/javadid the trick in case anyone is wondering in the future!
benva at 2007-7-13 8:26:54 > top of Java-index,Java Essentials,New To Java...
# 5
I'm glad that you figured it out because linux isn't one of my strong points.
Gita_Weinera at 2007-7-13 8:26:54 > top of Java-index,Java Essentials,New To Java...