Forum Stats

  • 3,826,609 Users
  • 2,260,677 Discussions


How can I import static members from another class?

I'm trying to import static members from another class. The code examples below are in separate .java files. TestStaticClassMember is compiled first using:


followed by:


TestStaticClassMember is not a recognised symbol to TestClass using the import construct:

import static TestStaticClassMembers.*;

featured within the examples below. Why is that?

public class TestStaticClassMember {

  public static double getDate(double in)


     return in;



import static TestStaticClassMember.*;

public class TestClass{


I've tried to recreate the compile error from the class (which has static members) and that wants to use those static members from RandomUtil.

These classes are in the tree package from tree_animation found in the Oracle documentation.