I use dr java for linux to run my code. I've been running into a bunch of errors recently while running this simple program. The code compiles fine but whenever I run the java file, I get the error;
Static Error: Undefined name
here's my code; (I've got two files, Square.java and SquareD.java)

public class Square{
private String name;
private int y;
private int x;

public Square(String st,int x2,int y2){
name=st;
x=x2;
y=y2;}

public int square(){
return x*x+y*y;}

double a1=(double) x;
double a2=(double) y;

public double hypotenuse(double a1,double a2){
  double sum = a1*a1+a2*a2;
return Math.sqrt(sum);}

public int area(){
return x*y;}

public String getName(){
return name;}
}

Here's Square.java;

public class Square{
private String name;
private int y;
private int x;

public Square(String st,int x2,int y2){
name=st;
x=x2;
y=y2;}

public int square(){
return x*x+y*y;}

double a1=(double) x;
double a2=(double) y;

public double hypotenuse(double a1,double a2){
  double sum = a1*a1+a2*a2;
return Math.sqrt(sum);}

public int area(){
return x*y;}

public String getName(){
return name;}
}

Whever I type java Square.java or java SquareD.java in the interactions window, I get,

Static Error: Undefined name

I'm running Ubuntu 11.10

Recommended Answers

All 2 Replies

Found the solution;
java Filename
or Run button at top right corner
I think this post should be taken down

Just mark it solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.