Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to compile program with classes in different packages

Status
Not open for further replies.

abc73

Programmer
Apr 28, 2004
89
US
Hi,
I am trying to run the application on a commandline. I am able to run it fine in JDeveloper as the application is created in JDeveloper. But I need to run it on a commandline. I need some help how to make it work. Here is the scenario:

I have two packages i.e.

com.test1.test2.all
com.test1.test2.util

I have four classes in each of the package.
My main class is in package com.test1.test2.all

When I try to compile the program, gets errors that say can't find the classes from package
com.test1.test2.util. As I have added import com.test1.test2.util.*; in classes of com.test1.test2.all.

here is what I am doing:

C:\test\com\test1\test2\all\javac MainClass.java

I get compilation errors: i.e.

can't find class com.test1.test2.util.Test2 and so on...


So can anyone help me what is the right way to do. Thanks for the help.
 
you need the classpath option to be specified:
javac -cp <path to all classes separated by ";"> MainClass.java

Bob Rashkin
rrashkin@csc.com
 
I got the javac command working but when I give the
java command to run it gives class not found error. How should I set the path for running the program.
Also when I compile what's the way to put the class-files in a diffrent folder. Any help is appreciated. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top