I'm new in Java and can not get idea of using packages. Am I stupid or is this some kind of bug?
Guys, how to deal with this error?
C:\Users\batievskiy\IdeaProjects\JavaPset\src>java Test.java
Test.java:1: error: package pkgcalculate does not exist
import pkgcalculate.Calculator;
^
Test.java:5: error: cannot find symbol
Calculator obj = new Calculator();
^
symbol: class Calculator
location: class Test
Test.java:5: error: cannot find symbol
Calculator obj = new Calculator();
^
symbol: class Calculator
location: class Test
3 errors
error: compilation failed

this is Calculator code:
package pkgcalculate;
public class Calculator {
public int add(int a, int b){
return a+b;
}
public static void main(String[] args){
Calculator obj = new Calculator();
System.out.println(obj.add(10, 20));
}
}
from what I got: that I cannot run Test.java from the terminal directly using: java Test.java But if I run Test with Shift + F10, the program is compiled. Why is that? Is it normal behaviour?
If you compiling your code from command line you have to compile classes you depend on first.
Or compile them all together in one go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With