File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Class Path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Class Path" Watch "Class Path" New topic

Class Path

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
My JDK will be in c:/program files

I have made my project & I will have to run my project from the command prompet .

What should I do . Is this process is correct :

1] I will put my all files in 'bin' folder that is inside jdk folder .

2] javac // For Compilation

3] java Start // For Execution

This method will work ?
Is there any other better method ?
What is the funda of class path & path ?

please reply ...
thanks .
Jef Cumps
Ranch Hand

Joined: Nov 14, 2001
Posts: 53

First of all, putting all your code (java files) in the bin directory of your JDK is NOT a good idea. Create a special directory for your poject somewhere, lets say c:\myproject. Then put all .java files in c:\myproject\src. If you put a Java class in a package (package com.myproject.blabla as first line in your class) then you need to create the package directory structure inside the src-dir. (would be c:\myproject\src\com\myproject\blabla in the given example).

To be able to run javac and java from your project directory, you need to put the bin directory of your JDK in your path. In a prompt you put: set PATH=%PATH%;c:\yourJDKdir\bin

Then you can call javac and java from within your project directory, pointing to the source files in the src dir, en maybe putting the class files in another dir (build) next to the src dir. Use javac -help for the syntaxt for this...

The classpath is where you need to put the things the compiler en jvm need to run. So if things don't work (class not found errors) put your src dir in the classpath.

Let me know if this helps... good luck!
I agree. Here's the link:
subject: Class Path
It's not a secret anymore!