0

error : package does not exist //HELP!

//This is my code to build a package. public void aClass(){ System.out.println("This is my package!"); } public static void main(String[] args){ MyPackageClass obj = new MyPackageClass(); obj.aClass(); } } //Then I tried to run the package. //Another java file import mypack.MyPackageClass; public class MyClass { public static void main(String[] args){ MyPackageClass obj = new MyPackageClass(); System.out.println(MyPackageClass()); } } //The name of the file match the class name. //The examples I went through is all in command prompt. But I am using //jgrasp so I will not see something like "javac –d .. demo.java" //so I think the examples do not suit me //Can U help explaining this? Thank you

23rd Mar 2019, 5:21 PM
GO!
GO! - avatar
2 Answers
+ 1
I don't know if it's going to help in your case, since I don't know what OS you are using, but on Windows, everytime you create some jar file, you have to add it to the CLASSPATH Environment Variable or place it in a folder that is checked by your environment (just as apache-tomcat). Perhaps it's the same for packages.
23rd Mar 2019, 8:44 PM
Luis Sepúlveda
Luis Sepúlveda - avatar
0
Ya I am using Windows, the classpath... ok I try to find the solution based on that keyword. But "add the java file to the CLASSPATH Envirionment Variable", does it means what we usually do, that is when I try to run a java file in JDK? By the way, I only knew the word "Environment variable" when I installed the JDK. Anyone please?
24th Mar 2019, 4:52 AM
GO!
GO! - avatar