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

Compilation error

vishal razdan

Joined: Aug 20, 2006
Posts: 5
hi friends ,

I am having a problem , while compiling a java file .
I have 2 java files :

1) in dir : C:\java\jdk1.5\bin
2) in dir : C:\java\jdk1.5\Temp

Source Files are as follows : :

package user;

import supplier.Supplier;

public class User {

public static void main(String[] args) {
Supplier supplier = new Supplier();
System.out.println("Reply ( In User ) : "+supplier.getReply());
} :

package supplier;

public class Supplier {

public String getReply() {
return "You will surely get it ..." ;

public static void main( String[] args ) {
Supplier s = new Supplier();
System.out.println("Reply ( In Supplier ) : "+s.getReply() );

Now , I want to compile
I have 2 options

1) First compile : & provide it's path in 'classpath' while compiling

C:\java\jdk1.5\Temp>javac -d "."

After adding its classpath to

C:\java\jdk1.5\bin >javac -d "." -classpath "C:\java\jdk1.5\Temp"

This works good .

2)Suppose i want to use sourcepath option :-

It does not find

On Compiling

C:\java\jdk1.5\bin >javac -d "." -sourcepath "C:\java\jdk1.5\Temp" , it gives error package supplier does not exist
import supplier.Supplier;
^ cannot resolve symbol
symbol : class Supplier
location: class user.User
Supplier supplier = new Supplier();
^ cannot resolve symbol
symbol : class Supplier
location: class user.User
Supplier supplier = new Supplier();
3 errors

Can you people please explain me , why i am gettting this problem ???
Praveen Babu
Ranch Hand

Joined: Jul 30, 2006
Posts: 138
C:\java\jdk1.5\bin >javac -d "." -sourcepath "C:\java\jdk1.5\Temp" , it gives error

You are specifying -sourcepath ie you are saying the compiler that your is in C:\java\jdk1.5\Temp directory which is not the case. Thats why you are getting this error. Use -classpath instead.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
This does not look like it is SCJP specific. Moving to Java In General Intermediate...

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Srinivas Kalvala
Ranch Hand

Joined: Oct 20, 2005
Posts: 257


Don't put source files in original java installation directory. Always it will be prefereble to work outside from installatin directory. Use a workspace to test all applicatin. Make your workspace as relative path to all your classpaths.
I agree. Here's the link:
subject: Compilation error
It's not a secret anymore!