• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

CLASSPATH problems

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am a beginner and I am having classpath problems! Here is where my files are located:

C:\Users\msm\Documents\Java_II_projects\HorseDA\Horses

My package statement in my 3 pgms is: package Horses;

What should my CLASSPATH variable be set to?

Right now, my project will only compile if I take the package statements out of my 3 pgms. If I leave the package statements in, I get all sorts of compile errors stating that this or that could not be found. Should all 3 java files and all 3 class files be in the same folder, or should the java files be in one folder and the class files be in a sub-folder? THANKS for your help!
 
Ranch Hand
Posts: 608
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take a deep breath!

1. Don't fiddle with the class path. If you are a beginner with Java - here some advice DO NOT TOUCH THE CLASSPATH. DONT EVEN THINK ABOUT IT.

2. Compiling packages can be tricky when not using an editor. You probably compiling it from the wrong place. Tell us (ok right now there is just me) the following ...
a. Which is the directory in which you are giving the Javac command?
b. Whats the command you are using to compile?

3. Should the java files be in one folder and the class files be in a sub-folder?
Doesn't matter - for someone starting off I'll leave both source and class files in the same directory.
Once you get the hang of things - well you won't be hand coding anyways - Your IDE will make sure everything happens nicely.

PS - Just some additional help --> http://www.javaranch.com/name.jsp before a Sheriff catches you
 
Ranch Hand
Posts: 326
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1- Error messages are appreciated

2- Feel free to do whatever you want with the classpath. Experimentation and finding out what doesn't work goes a long way towards mastery - besides, it's not like you'll break it.

3- When compiling, the classpath should include the package root (the path to the folder that contains the highest level of your package structure), in this case it is C:\Users\msm\Documents\Java_II_projects\HorseDA;

 
That new kid is a freak. Show him this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic