Package Does Not Exist In Java Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more java package does not exist jar about Stack Overflow the company Business Learn more about hiring developers or posting java package does not exist intellij ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack
Package Does Not Exist Maven
Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up package does not exist error! up vote 5 down vote favorite
Package Does Not Exist Java Command Line
1 I have a directory structure like com/example/web under the root directory which contains a java file Bear.java. I have another java file BearExtra.java in directory structure com/example/model in same root directory as above. I am calling a method in BearExtra.java from Bear.java and I am getting the error that the package does not exist. I have imported com.example.model package in my java file. Can give me some advice? java error package system does not exist java import packages share|improve this question edited Jul 12 '11 at 14:06 Bart Kiers 107k23187217 asked Jul 12 '11 at 14:02 rdx 43115 1 Can you show us the code you have? –Mario Duarte Jul 12 '11 at 14:04 3 Did the compiler really say package does not exist error!! ? –Sebastian Mach Jul 12 '11 at 14:08 add a comment| 2 Answers 2 active oldest votes up vote 9 down vote accepted This works: com/example/model/BearExtra.java package com.example.model; public class BearExtra { public static void go() { System.out.println("Yay, it works!"); } } com/example/web/Bear.java package com.example.web; import com.example.model.*; public class Bear { public static void main(String[] args) { BearExtra.go(); } } Now, to compile and run these classes, go to the directory where you can "see" the com folder and do: *nix/MacOS javac -cp . com/example/model/*.java com/example/web/*.java java -cp . com.example.web.Bear Windows javac -cp . com\example\model\*.java com\example\web\*.java java -cp . com.example.web.Bear and the following is being printed to the console: Yay, it works! share|improve this answer answered Jul 12 '11 at 14:16 Bart Kiers 107k23187217 thanks a lot...it is working now....there was an error in the compiling command –rdx Jul 12 '11 at 14:25 add a comment| up vote 0 dow
This Site Careers Other all forums Forum: Java in General "package does
Package Does Not Exist Netbeans
not exist" error Shajid Johnny Ranch Hand Posts: error package java.time does not exist 34 posted 6 years ago Dear members, I am developing a Java web error package does not exist android studio project. in my 'src' folder- I have the following two classes: 1) package com.foo.model; //import statements public class BookExpert{ //some method http://stackoverflow.com/questions/6665420/package-does-not-exist-error implementation } 2) package com.foo.controller; import com.foo.model.*; public class BookSelectServlet extends HttpServlet{ public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{ //calling the model class BookExpert be = new BookExpert(); } } First, from my project root directory I compiled the model class: https://coderanch.com/t/496550/java/java/package-exist-error E:\SCWCD preparation\HF Projects\javaEbook>javac -cp "C:\My Tools\apache-tomcat- 6.0.20\apache-tomcat-6.0.20\lib\servlet-api.jar" -d classes src\com\foo\model\BookExpert.java But later when I tried to compile the controller servlet: E:\SCWCD preparation\HF Projects\javaEbook>javac -cp "C:\My Tools\apache-tomcat- 6.0.20\apache-tomcat-6.0.20\lib\servlet-api.jar" -d classes src\com\foo\controller\BookSelectServlet.java I got the following errors: src\com\foo\controller\BookSelectServlet.java:8: package com.foo.model does not exist import com.foo.model.*; ^ src\com\foo\controller\BookSelectServlet.java:25: cannot find symbol symbol : class BookExpert though the model class BookExpert was successfully built inside the classes/com/foo/model directory, still the controller servlet did not compile please anyone help me out of the pain i am suffering from the last night Steve Luke Bartender Posts: 4181 22 I like... posted 6 years ago You never add "E:\SCWCD preparation\HF Projects\javaEbook\classes\" to your classpath, so the package found at E:\SCWCD preparation\HF Projects\javaEbook\classes/com/foo/model/ can't be found. Steve Shajid Johnny Ranch Hand Posts: 34 pos
exist error? I get these errors https://teamtreehouse.com/community/what-is-a-package-does-not-exist-error Example.java:1: error: package com.teamtreehouse does not exist import com.teamtreehouse.Treet; ^ Example.java:6: error: cannot find symbol Treet treet = new Treet(); ^ symbol: class Treet location: class Example Example.java:6: error: cannot find symbol Treet treet = new Treet(); ^ symbol: class Treet location: class does not Example 3 errors Thanks 1 Answer MOD Ryan Ruscett Treehouse Moderator 16,253 Points Ryan Ruscett Ryan Ruscett Treehouse Moderator 16,253 Points about 1 year ago Hey, packages you use the keyward. "package" Not import. package com.example; That is how you add the package. Then does not exist once the packages is added, you can import things from it. does the make sense? Posting to the forum is only allowed for members with active accounts. Please sign in or sign up to post. Our mission is to bring affordable, technology education to people everywhere, in order to help them achieve their dreams and change the world. Our Company About Us Contact Us Community Treehouse Stories Student Perks Treehouse Blog Affiliate Program Careers Topics HTML CSS Design JavaScript Ruby PHP WordPress iOS Android Development Tools Business Tracks Web Design Web Development Rails Development PHP Development iOS Development Android Development WordPress Development Starting a Business Treehouse Blog About Treehouse Privacy Policy Terms & Conditions © 2016 Treehouse Island, Inc. Sign in Email Address Password I forgot my password Sign in