Hi,
I entered the below code and it ran fine. Be careful with accessiblity in OtherClass. Since it is declared in a different package, I defined it as public. Also, a semicolon was added as noted in the code.
To compile I did the following:
//The -d creates the directories if they are not there
javac -d . OtherClass.java
javac Testing.java
java Testing
Also, you could test OtherClass by running it.
import com.pack.*;
public class Testing
{
public static void main (String args[])
{
OtherClass oc = new OtherClass(); // Semicolon was missing
}
}
// File OtherClass
package com.pack;
public class OtherClass {
public OtherClass() { System.out.println("OtherClass constructor"); }
public static void main(String args []) { OtherClass o1 = new OtherClass(); }
}
I hope this helps.