• Post Reply Bookmark Topic Watch Topic
  • New Topic

Compiling java files  RSS feed

 
feda alshahwan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
feda alshahwan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Swastik Dey
Rancher
Posts: 1815
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
feda alshahwan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also I did the following but I got the following error



 
Swastik Dey
Rancher
Posts: 1815
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
feda alshahwan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I set the path from windows in detail please
 
Swastik Dey
Rancher
Posts: 1815
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ankit Garg
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!