Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Please take a look at this code and help with the compile error

Avatar of jtiernan2008
jtiernan2008 asked on
Java
3 Comments1 Solution312 ViewsLast Modified:
I have two classes but the Multilateration class will not compile because of compile error
ompiling 1 source file to C:\Users\Justin\Documents\NetBeansProjects\JavaApplication2\build\classes
C:\Users\Justin\Documents\NetBeansProjects\JavaApplication2\src\Multilateration.java:9: non-static method getValue(int) cannot be referenced from a static context
                double ti = OrgData.getValue(sel), tk = OrgData.getValue(sel+1), tj = OrgData.getValue(sel+2), tl = OrgData.getValue(sel+3);
                                   ^
C:\Users\Justin\Documents\NetBeansProjects\JavaApplication2\src\Multilateration.java:9: non-static method getValue(int) cannot be referenced from a static context
                double ti = OrgData.getValue(sel), tk = OrgData.getValue(sel+1), tj = OrgData.getValue(sel+2), tl = OrgData.getValue(sel+3);
                                                               ^
C:\Users\Justin\Documents\NetBeansProjects\JavaApplication2\src\Multilateration.java:9: non-static method getValue(int) cannot be referenced from a static context
                double ti = OrgData.getValue(sel), tk = OrgData.getValue(sel+1), tj = OrgData.getValue(sel+2), tl = OrgData.getValue(sel+3);
                                                                                             ^
C:\Users\Justin\Documents\NetBeansProjects\JavaApplication2\src\Multilateration.java:9: non-static method getValue(int) cannot be referenced from a static context
                double ti = OrgData.getValue(sel), tk = OrgData.getValue(sel+1), tj = OrgData.getValue(sel+2), tl = OrgData.getValue(sel+3);
                                                                                                                           ^
4 errors

The Orgdata class compiles fine.

The Multilateration class invokes the getValue method of Orgdata which accesses a simple mysql database and gets the three time values with respect to the rNum which is just an incrementer used to locate the values in the database.

Can someone please have a look
import java.lang.Math;
 
public class Multilateration {
	
	 
       	void calcCord(int sel) {	
            
         
		double ti = OrgData.getValue(sel), tk = OrgData.getValue(sel+1), tj = OrgData.getValue(sel+2), tl = OrgData.getValue(sel+3);
		double xi = -8, xk = 15338349, xj = 0, xl = 2656680;
		double yi = 21482069, yk = 15338349, yj = 6380000, yl = 0;
		double zi = 3683495, zk = 15338349, zj = 25789348, zl=0;
		
		double xji=xj-xi; double xki=xk-xi; double xjk=xj-xk; double xlk = xl-xk;
		double xik=xi=xk; double yji=yj-yi; double yki=yk-yi; double yjk=yj-yk;
		double ylk=yl-yk; double yik=yi-yk; double zji=zj-zi; double zki=zk-zi;
		double zik=zi-zk; double zjk=zj-zk; double zlk=zk;
		
		double rij=Math.abs((10*(ti-tj))/33); double rik=Math.abs((10*(ti-tk))/33);
		double rkj=Math.abs((10*(tk-tj))/33); double rkl=Math.abs((10*(tk-tl))/33);
		
		double s9=rik*xji-rij*xki; double s10=rij*yki-rik*yji; double s11=rik*zji-rij*zki;
		double s12=(rik*(rij*rij+xi*xi-xj*xj+yi*yi-yi*yj+zi*zi-zj*zj)
			   -rij*(rik*rik+xi*xi-xk*xk+yi*yi-yk*yk+zi*zi-zk*zk))/2;
			   
		double s13=rkl*xjk-rkj*xlk; double s14=rkj*ylk-rkl*yjk; double s15=rkl*zjk-rkj*zlk;
		double s16=(rkl*(rkj*rkj+xk*xk-xj*xj+yk*yk+zk*zk-zj*zj)
			-rkj*(rkl*rkl+xk*xk-xl*xl+yk*yk-yl*yl+zk*zk-zl*zl))/2;
			
		double a=s9/s10; double b=s11/s10; double c=s12/s10; double d=s13/s14;
		double e=s15/s14; double f=s16/s14; double g=(e-b)/(a-d); double h=(f-c)/(a-d);
		double i=(a*g)+b; double j=(a*h)+c;
		double k=rik*rik+xi*xi-xk*xk+yi*yi-yk*yk+zi-zk*zk+2*j*yki;
		double l=2*(g*xki+i*yki+zki);
		double m=4*rik*rik*(g*g+i*i+l)-l*l;
		double n=8*rik*rik*(g*(xi-h)+i*(yi-j)+zi)+2*l*k;
		double o=4*rik*rik*((xi-h)*(xi-h)+(yi-j)*(yi-j)+zi*zi)-k*k;
		double s28=n/(2*m); double s29=(o/m); double s30=(s28*s28)-s29;
		double root=Math.sqrt(s30); 
		System.out.println();
		int z1=(int)(s28+root); System.out.println("z = "+ z1 + "\n");
		int z2=(int)(s28-root); // System.out.println("z1 = "+z2+"\n");
		int x1=(int)(g*z1+h); System.out.println("x = "+x1+"\n");
		int x2=(int)(g*z2+h); // System.out.println("x2 = "+x2 +"\n");
		int y1=(int)(a*x1+b*z1+c); System.out.println("y = " + y1 + "\n");
		int y2=(int)(a*x2+b*z2+c); // System.out.println("y2 = " +y2 + "\n");
	}
			
	}
	
 
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
 
public class OrgData {
 
      int a, b;
 
      final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
      final String DATABASE_URL = "jdbc:mysql://localhost:3306/rfiddata";
      Connection connection = null; // manages connection
      
      int getValue(int rNum) {
            try {
                  Class.forName(JDBC_DRIVER); // load database driver class
 
                  // establish connection to database
                 connection = DriverManager.getConnection(DATABASE_URL, "root", "");
 
                  // create Statement for querying database
                  Statement statement = connection.createStatement();
                  ResultSet rs1 = statement.executeQuery("select time from rfid where rnum=sel");
                  a = rs1.getInt("time");
                  return a;
 
            } // end try
            catch (SQLException sqlException) {
                  sqlException.printStackTrace();
                  System.exit(1);
            } // end catch
 
            catch (ClassNotFoundException classNotFound) {
                  classNotFound.printStackTrace();
                  System.exit(1);
            } // end catch
            finally // ensure statement and connection are closed properly
            {
                  try {
 
                        connection.close();
                  } // end try
                  catch (Exception exception) {
                        exception.printStackTrace();
                        System.exit(1);
                  } // end catch
            } // end finally
          return 0;
  } // end main
 
 
}// end class
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers