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 7 of 7

Thread: CLASSPATH environment variable

  1. #1
    Member
    Join Date
    Feb 2011
    Location
    Pittsburgh
    Posts
    62
    My Mood
    Angelic
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Exclamation CLASSPATH environment variable

    Greetings.

    ME JAVA YOU JANE.
    I have completed a course in Java and have a smigen of knowledge about the programming language Java. Happy with that, but we where using a text editor for Java and I find my self lost not by the code, but by the files and actually getting to use java in the real world.

    MY ATTEMPTED SEARCH FOR KNOWLEDGE
    To that end I bought (took out from the library, but now will buy my self a copy), of Horton the Elephant Java 2 5th edition. This book tells me it will take me to the point I can actually get a website up, simple, but up. Yes sir I put on my helmet and I am ready to go.

    THE QUESTION
    I am unhappy and/or blind, because I do not understand where or how I would identify a Classpath environment variable, one of the first topics. I don't think I would have a problem figuring this out if I knew what screen to be in to type commands. Do I need to open "run" command from the start menu (windows), then type something in?
    If so what do i type in?

    I am lost at the very beginning, that and the organization of the files holding the classes I call in a program, but that is another story.

    So thanks from all the space monkeys around, and smoke me a kipper I will be back for breakfast!


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: CLASSPATH environment variable

    classpath tells Java where to look for java class files.

    For example, say I had the following folder structure:
    • C:\
      • Java
        • Project1
          • bin
            • package1
              • class1.class
              • class2.class
            • package2
              • class3.class
              • class4.class


    All the class files are located under C:\Java\Project1\bin, so I would use that as the classpath. Depending on where you put your files (as well as your package structure), you'll have a different classpath.

    for more information on the classpath, see: Setting the class path
    Last edited by helloworld922; February 10th, 2011 at 02:30 AM.

  3. #3
    Member
    Join Date
    Feb 2011
    Location
    Pittsburgh
    Posts
    62
    My Mood
    Angelic
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Arrow Re: CLASSPATH environment variable

    Dear Venerated Enlightened One:

    Thanks for the info. I guess my problem is that, when you say "All the class files are located under C:\Java\Project1\bin, so I would use that as the classpath."

    My question is "Where do I put, enter, or otherwise entertain the classpath?"

    Do I put the classpath it in the code?

    Do I open "run", type something in, then from that black screen with the funny type setting, enter the class path information there.

    I am not so worried about the "C:\Java\Project1\bin", so much as I am lost as to the venue to enter this information. I do not know WHERE to enter the classpath.

    The hole file thing is a mystery to me.

    If I create a class "BanaNana" I know I have to save it as a file BanaNana.java.
    But do I then have to save it in a FOLDER called "BanaNana"?

    Then, how do I get the java compiler to take an interest in it?

    I am going to read the rest of the first chapter to see if I can expose my mind to thought, and maybe answer my own questions.

    Ooo Ooo Ooooo (Thanks and good night)
    Again thanks for your help.

  4. #4
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: CLASSPATH environment variable

    Did you read the link I posted? It gives details on how to set the classpath and where to set it to.

  5. #5
    Member
    Join Date
    Feb 2011
    Location
    Pittsburgh
    Posts
    62
    My Mood
    Angelic
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default Re: CLASSPATH environment variable

    Dear HellowWorld22:

    Thanks for the response, but you missed the beginning of my problem, I was not sure how to use the "run" command and not sure how to use "cmd" to get into it, so this link:
    "Hello World!" for Microsoft Windows (The Java™ Tutorials > Getting Started > The "Hello World!" Application)

    Gave me the very beginnings I needed. Now I know where I have to change the classpath. to get javac to work. You did help me by helping narrow my search to the tutorials.

    So that was the first part of the journey over. Now I have the problem of actually changing the classpath and I am no closer and here is why.

    I have not been saving my files under java, I was saving them under documents. I am completely unschooled on this folder stuff. I don't know what I don't know. (Where's Rumsfelt?)
    Had to put “Program Files” in “Quotations” in the Run.. Screen when I was trying to access that file, and took ages to work that out.

    Then I changed the current working directory to the folder with the file.

    Then I followed the path to the javac command thing (yep thing) (Thanks you gave me the link that solved that problem. and then it came back "Access is Denied" What?

    Please god tell me that you can point me in the direction of getting access to this, whatever it is.

    Every step I take is a step back it seems.

    Thanks.

    TheWhiteBear
    Last edited by SPACE MONKEY; February 15th, 2011 at 11:36 AM.

  6. #6
    Member
    Join Date
    Feb 2011
    Location
    Pittsburgh
    Posts
    62
    My Mood
    Angelic
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default Re: CLASSPATH environment variable

    Update:

    Move the file out of the Java folder and all is good, finally managed to create the .class file. Thanks for all your help.

    TheWhiteBear aka SPACE MONKEY aka Kevin

  7. #7
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: CLASSPATH environment variable

    Glad you got it figured out
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. Issues with Static environment
    By almostlowfatmilk in forum What's Wrong With My Code?
    Replies: 7
    Last Post: January 19th, 2011, 03:26 PM
  2. Environment issue with Bonjour API
    By DarkRoast in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 29th, 2010, 08:02 PM
  3. Graphic Environment Abstract Methods
    By striko_514 in forum Java Theory & Questions
    Replies: 2
    Last Post: July 5th, 2010, 01:01 AM
  4. Problems in setting classpath
    By missyati in forum Java Theory & Questions
    Replies: 3
    Last Post: June 30th, 2009, 12:43 AM
  5. Replies: 1
    Last Post: July 10th, 2008, 05:03 AM

Tags for this Thread