It's not a secret anymore!
The moose likes Beginning Java and the fly likes Compile and deploy from DOS prompt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compile and deploy from DOS prompt" Watch "Compile and deploy from DOS prompt" New topic

Compile and deploy from DOS prompt

Ed Mirsky

Joined: Apr 22, 2005
Posts: 11
I�m a novice and I need help.

To make the notation simpler (I hope),
Let D� mean Directory
Let DD� mean subdirectory

I was as able to run my application from the DOS command prompt when it had the following structure:

D� myJ2
DinnerMenu.class (has main(String args[] and uses SpringUtilities)
Calculator.class ( a dialog which uses SpringUtilities)
SquareRootDialog.class (a dialog which uses SpringUtilities)
DD�pac (a subdirectory with many directories)

I decided to put Calculator.class and SquareRootDialog.class in a directory called dlg, and I put SpringUtilities.class into a directory called utl. The new structure of the application is:

D� myJ2
DD� utl
DD� dlg
DD� pac
Classes used by Calculator and SquareRootDialog

I import SpringUtilities into DinnerMenu, Calculator, and SquareRootDialog with:
import utl.SpringUtilities;

import SpringUtilities;

( Problem 1)
I need to recompile Calulator.class and SquareRootDialog.class before compiling DinnerMenu.class, but I can�t figure out how to do that. (I�ve been trying for a week.)

I�ve tried the following without success to compile Calculator:

C:\myJ2\dlg>path= C:\Program Files\Java\jdk1.5.0_03\bin
C:\myJ2\dlg>set CLASSPATH=C:\myJ2\utl;C:\myJ2\pac;C:\myJ2\dlg
C:\myJ2\dlg> javac -classpath %CLASSPATH%

SAMPLE ERROR MESSAGE --------------------------------------- package pac.libr.mat does not exist
import pac.libr.mat.MathLibrary;
^ package pac.libr.sta does not exist
import pac.libr.sta.StatLibrary;
^ package utl does not exist
import utl.SpringUtilities;

------------------------------------------- END ERROR MESSAGE

(Problem 2)
I want to create an executable JAR file. Will this do the job?
C:\>myJ2jar cvf DinnerMenu.jar DinnerMenu*.class dlg

(Problem 3)
Ultimately, I want to run the application. Will this do the job?
C:\myJ2>set CLASSPATH=C:\myJ2\myJar.jar
C:\myJ2>java -classpath "./DinnerMenu.jar" DinnerMenu

(Problem 4)
One last question. I think the jdk1.5 has SpringUtilities. Can I eliminate SpringUtilities.class from my application and import it into DinnerMenu and Calculator with something like: import SpringUtilities;

Thanks in advance for you help,

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63348

Not an Ant or Maven question as far as I can tell, so moved to the Java in General (beginner) forum.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Compile and deploy from DOS prompt
It's not a secret anymore!