UnsupportedClassVersionError
Hi!
I'm a java newbie and I'm learning from the book Beginning Java 2
I have the following code from the book stored and it works from the jdk\bin directory but when I compile and attempt to execute it in a new directory I get the exception in the subject above.
Code:
class Sphere
{
static final double PI = 3.14; // Class variable that has a fixed value
static int count = 0; // Class variable to count objects
// Instance Variables
double radius; // radius of a sphere
double xCenter;
double yCenter;
double zCenter;
// Class constructor
Sphere(double theRadius, double x, double y, double z)
{
radius = theRadius;
// Set the coordinates of the center
xCenter = x;
yCenter = y;
zCenter = z;
++count;
}
// Static method to report the number of objects created
static int getCount()
{
return count;
}
// Instance method to calculate volume
double volume()
{
return 4.0/3.0*PI*radius*radius*radius;
}
}
class CreateSpheres
{
public static void main(String[] args)
{
System.out.println("Number of objects = " + Sphere.getCount());
Sphere ball = new Sphere(4.0,0.0,0.0,0.0); // Create a sphere
System.out.println("Number of objects = " + ball.getCount());
Sphere globe = new Sphere(12.0,1.0,1.0,1.0); // Create a sphere
System.out.println("Number of objects = " + Sphere.getCount());
// Output the volume of each sphere
System.out.println("ball volume = " + ball.volume());
System.out.println("globe volume = " + globe.volume());
}
}
in the system path I have the following
;C:\Program Files\Java\jdk1.6.0_03\bin;C:\Program Files\Java\jdk1.6.0_03\jre
any help with this is appreciated.
Thanks,
T
|