code below
import com.sun.tools.javac.util.Abort;
public class Test {
public static void main(String[] args) {
System.out.println("hello world");
}
}
use javac to compile this file, compile error like this
com.sun.tools.javac.util doesn't exist
I'm using mac, here is my java -version output
openjdk version "1.8.0_265"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_265-b01)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.265-b01, mixed mode)
The package
com.suncontains Oracle private JDK classes (see more here, and the offical statement).You are running OpenJdk and this JDK doesn't include Sun's packages.
2 solutions:
Note that using
com.sunpackages in an application is seen as a bad practice for this exact reason.