0

Im making a program in java, that uses multiple java files and packages in NetBeans Error is Here:

package hardware;
import software.Firmware;
/**
 *
 * @author x1010
 */
public class Router {
Firmware os = new Firmware ();
os.UkazTypZarizeni();
}

Class Firmware:

package software;

import test.Shrt;

/**
*
 * @author x1010
*/
public class Firmware  {
private final Shrt s = new Shrt();
public String TypZarizeni = null;
public void UkazTypZarizeni () {
 if(TypZarizeni != null) {  
    s.print("Typ Zarizeni = " + TypZarizeni); 
   } else {
     s.print("Typ Zarizeni: Nezname Zarizeni");
   }

  }
  public void NastavitTyp (String TypA) {
  TypZarizeni = TypA;
  s.print("Typ Zarizeni Zmenen na " +  TypA);
  }   
 }

In Class Router, on the line os.UkazTypZarizeni(); It says: Package os does not exist. Help please! And sorry for my terrible English and the program in czech >]

3
  • 1
    You have a space in Firmware os = new Firmware (); It must be Firmware os = new Firmware(); Commented Jul 11, 2016 at 8:58
  • 2
    You need to put the code inside Router into a method. You can't have bare code directly in the class. Commented Jul 11, 2016 at 8:59
  • @RadouaneROUFID It's perfectly valid to put a space there. Commented Jul 11, 2016 at 8:59

1 Answer 1

1

You have to provide a method name in router class. You can not call the method of another class without writing a method in the calling class.

    package hardware;
    import software.Firmware;
    /**
     *
     * @author x1010
     */


 public class Router {

    void callUkazTypZarizeni {  //TODO correct the method name.

    Firmware os = new Firmware ();
    os.UkazTypZarizeni()
    }
}

Please let me know if your are still facing the issues.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.