Accessing a class file from Netbeans source file

365 Views Asked by At

I am using Netbeans 7. I was provided with a class file (MT.class), that I need to test. I put it under build>classes.

I created a java class with main method. When I declare a new object using MT class, I get compiler error. Please let me know how to resolve this.

package mypack;

public class MyTest {

public static void main(String[] args) {

   MyTest.avgTest();

}

public static void avgTest()
 {

double res;

MT mt=new MT();

res=mt.avg(9,4);


 System.out.println("The average is " + res);
 }


 }
1

There are 1 best solutions below

0
nullPointer On

If your .class file was compiled under a specific package hierarchy / dir structure, just create this structure under /libs . So if you class full name is foo.bar.MT then create /libs/foo/bar/ and put the .class file inside. Then right click on your project in NetBeans > Properties > Libraries > Add JAR/Folder > then select the the libs folder from the above example.