Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Package x does not exist????

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Package x does not exist????

    Hi

    I'm new to Java but not new to coding in general - I have a background in C programming. However, this error is driving me nuts! I have my environment variable CLASSPATH set to my NetBeans projects folder, and I've set the classpath in NetBeans to the same folder. I've built a test lib there called MyLib, but when I try and import that lib from another package with 'import com.domain.mylib.*;', I get the error saying the package doesn't exist! I'm probably making a rookie error here, but any help most welcome.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Package x does not exist????

    The java programs use the CLASSPATH variable to find class definitions. The CLASSPATH should be the location of the class files like a folder or a jar file. It won't look for jar files to search. The path to the jar file must be in the classpath. For example:
    java.exe -cp .;acm.jar ClassName


    I don't know how to configure your IDE.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Dec 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Package x does not exist????

    So, does CLASSPATH need to be set to the exact folder holding the .class files? The book I'm working through seems to suggest I just need to set CLASSPATH to the folder holding all my packages.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Package x does not exist????

    If the class files are not in a jar file, then the CLASSPATH needs to point to the folder containing the folder that is the head of the package name. Given package= com.mystuff, the CLASSPATH should reference the folder that contains the com folder. CLASSPATH + package name = full path to the class file.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Dec 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Package x does not exist????

    OK, I think I've got it now. Thanks!

Similar Threads

  1. Package does not exist
    By AceX in forum Java Theory & Questions
    Replies: 5
    Last Post: February 22nd, 2013, 04:11 PM
  2. Replies: 4
    Last Post: November 8th, 2012, 07:55 AM
  3. Problem with Excelapi: Error: package jxl does not exist
    By Rob Aiello in forum What's Wrong With My Code?
    Replies: 13
    Last Post: February 21st, 2012, 09:52 PM
  4. Simple package problem, package does not exist error
    By Farmer in forum Object Oriented Programming
    Replies: 3
    Last Post: August 23rd, 2011, 11:18 AM
  5. PROBLEM CHECKING IF RECORDS EXIST OR DO NOT EXIST IN DATABASE
    By jimmyb0206 in forum JDBC & Databases
    Replies: 1
    Last Post: April 10th, 2011, 09:18 AM