aspose file tools
The moose likes Beginning Java and the fly likes Compiling java files Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Compiling java files" Watch "Compiling java files" New topic
Author

Compiling java files

feda alshahwan
Ranch Hand

Joined: Jul 26, 2008
Posts: 170
If my java is stored in C:\Documents and Settings\Welcome\workspace\transform\src\com\coderanch\jaxws\passxml and I would like to compile a file how can I do it??
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16695
    
  19


Well, assuming the top of the hierarchy is the C:\Documents and Settings\Welcome\workspace\transform\src directory. And YourClass is in the com.coderanch.jaxws.passxml package. And you classpath is not set... then this would probably work best...

---> cd "\Documents and Settings\Welcome\workspace\transform\src"
---> javac com\coderanch\jaxws\passxml\YourClass.java

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
feda alshahwan
Ranch Hand

Joined: Jul 26, 2008
Posts: 170
I did what you told me but I got the following:


C:\Documents and Settings\Welcome\workspace\transform\src>javac -d . DomUtil.jav
a
'javac' is not recognized as an internal or external command,
operable program or batch file.

C:\Documents and Settings\Welcome\workspace\transform\src>
Ankit Garg
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9189
    
    2

feda you need to add the bin folder of your java installation to the path environment variable. If you have installed java here

c:\program files\java\jdk1.6.0_07

then your path environment variable must contain

c:\program files\java\jdk1.6.0_07\bin


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Swastik Dey
Ranch Hand

Joined: Jan 08, 2009
Posts: 1196

your path environmental variable is not properly set. You need to set the path as follows before you compile your code. I assume your jdk is installed as follows C:\Program Files\Java\jdk1.5.0_06, then before you compile your code type the following command prompt

set path=%path%;C:\Program Files\Java\jdk1.5.0_06\bin;.

the java path might change depending upon your installation.
now execute your code.


Swastik
feda alshahwan
Ranch Hand

Joined: Jul 26, 2008
Posts: 170
Also I did the following but I got the following error



Swastik Dey
Ranch Hand

Joined: Jan 08, 2009
Posts: 1196

javac "C:\Documents and Settings\Welcome\workspace\transform\src\com\coderanch\jaxws\passxml\DomUtil.java"

put it within double quotes, most likely dos does not recognizes spaces.
Sachin Adat
Ranch Hand

Joined: Sep 03, 2007
Posts: 213
feda alshahwan wrote:Also I did the following but I got the following error

Did you do what Ankit told you to do?
Your OS has to know where to find the javac(ie the java compiler) and java (interpreter) to compile and run your commands.
If you are using windows, you need to set the environment variables or at least set the path as Ankit said.


SCJP 6
How To Ask Questions On Java Ranch - How To Answer Questions On Java Ranch
feda alshahwan
Ranch Hand

Joined: Jul 26, 2008
Posts: 170
How can I set the path from windows in detail please
Swastik Dey
Ranch Hand

Joined: Jan 08, 2009
Posts: 1196

I have already mentioned it in my last post. However that is for that particular session, once you close the command window its lost and you have to reset it.
If you wish to set it permanently following steps should help you

My Computer->Properties->Advanced->Environmental Variable

Now select path click edit

at end put a ; and paste the path of jdk\bin and put a ;.

for e.g.

;C:\Program Files\Java\jdk1.5.0_06\bin;.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 9950
    
    6

feda alshahwan wrote:How can I set the path from windows in detail please

The 'details' would depend on what exact OS you have. Each version of windows (which is what I assume you are using) will do it slightly differently.


Never ascribe to malice that which can be adequately explained by stupidity.
Ankit Garg
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9189
    
    2

Just use the syntax given by Swastik

set path=%path%;C:\Program Files\Java\jdk1.5.0_06\bin

It is independent of the version of Windows...
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Compiling java files
 
Similar Threads
Crypted Strings in a file
Why we choose java?
What java methods to use?
hi, i have problem in reading data
i love java