• 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

Packages, directory structures, javac -d and CLASSPATH

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, after doing some major brainstorming, researching, reading and testing, I'd like to get a confirmation on whether I'm using all of the things in the Subject line correctly (I'm running Windows 2000, BTW):
2 source files:
//First src file saved as Test.java
package testPackage;
public class Test {...}
//Second src file saved as TestingTest.java
import testPackage.*;
public class TestingTest extends Test {...}
Directory structure: C:\Java\Sources for, well, *.java sources. C:\Java\Objects for *.class files.
The compiling is done from the C:\Java\Sources directory by issuing javac -d C:\Java\Objects *.java, which creates TestingTest.class in the CLASSPATH directory, then testPackage directory in the CLASSPATH directory, and lastly the Test.class in the newly created directory.
To call the TestingTest I issue java TestingTest from anywhere (that's where CLASSPATH comes in handy I guess), and to call Test I issue java testPackage.Test.
Ok, all is working fine, however, here are some things that I'm still not quite clear about:
Somehow I believed that one needs to specify just the root directory (in my case C:\Java) in the CLASSPATH. However, it doesn't seem to work, but adding \Objects\ fixes it... Another understanding (however possibly wrong) was that javac -d and CLASSPATH were related, i.e. I wouldn't need to specify the whole path, just the last directory for compiling. So instead of the example above the setup should have been C:\Java for CLASSPATH, then issue javac -d \Objects\ *.java to compile from the sources directory. That doesn't work as well. So what is the correct setup then and is there a relationship between CLASSPATH variable and javac -d?
Thanx for any clarification,
Sergey
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I found this url: http://mindprod.com/classpath.html
very helpful in my understanding of classpaths. I hope it helps you.
Allen
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic