• Post Reply Bookmark Topic Watch Topic
  • New Topic

CLASSPATH problems  RSS feed

 
A Peters
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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!
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • 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
 
Ray Stojonic
Ranch Hand
Posts: 326
  • Mark post as helpful
  • send pies
  • 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;

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!