I get a compile error in MyTest.java. It doesn't recognize the method MyFunc which it calls. Here's what I have, Both MyTest.java and MyClas.java are in c:\java. After succesfully compiling MyClass.java, I copied MyClass.class to my c;\java\com\util directory, since MyTest.java imports it. I want to call the MyFunc function in MyClass.java from main in MyTest.java. Also, it it OK to have a .java class file (such as my MyClass.java) that does NOT have a function main in it?
Here's my MyClass.java file:
package com.util;
public class MyClass
{
void MyFunc()
{
System.out.println("It printed in MyClass");
}
}
Here's my MyTest.java file:
import com.util.*;
public class MyTest
{
public static void main(
String[] args)
{
MyTest obj = new MyTest();
obj.MyFunc();
}
}