-5

I'm having a problem importing from a java class.

Here is my program:

import MyStuff.*;
public class Monday2
{
    public static void main(String[] args)
    {
        p("\n\n\n\t\tGood Morning from the Morning2 Class.\n\n\n");
    }
}

Here is the MyStuff class:

public class MyStuff
{
    public static final void p(String inputString)
    {
        System.out.println(inputString);
    }
}

Please tell me what I am doing wrong

Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
Nicky2017
  • 7
  • 1
  • 1
  • 2
    You haven't told what the problem is – Thiyagu May 07 '18 at 15:32
  • Monday2.java:1: error: cannot find symbol import static Stuff.*; ^ symbol: class Stuff Monday2.java:6: error: cannot find symbol p("\n\n\n\t\tHello from Monday2 Program !\n\n\n"); ^ symbol: method p(String) location: class Monday2 2 errors – Nicky2017 May 07 '18 at 18:59
  • I actually got this to work with Eclipse by exporting and importing the jar files etc. I'm having problems doing this from the command line. I guess I need to read up on the jar utility , my code is probably not creating my jar file. – Nicky2017 May 07 '18 at 20:01

2 Answers2

3

You forgot magic word - static, after your import like this

import static MyStuff.*;

You can read more in appropriate topic.
Hope it helps!

Sergey Prokofiev
  • 1,815
  • 1
  • 12
  • 21
2

Instead of import MyStuff.*; just use import static MyStuff.p; For more details please also see What does the "static" modifier after "import" mean?