This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes java compiler in java6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java compiler in java6" Watch "java compiler in java6" New topic
Author

java compiler in java6

Jyoti Vaskar
Ranch Hand

Joined: Jun 30, 2009
Posts: 142

hi all,

In java 1.6 the javac file is java.exe???

Im trying to download Java1.6 but not getting the javac file with jdk6.

can anybody tell me where I'll get the jdk with java compiler on the sun's site or other???

I am confused with various downloads on the site!!!

thank you.


thanks
Jyo
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18874
    
  40

If the compiler is not included with the package, then you probably downloaded the runtime environment (JRE) and not the development kit (JDK).

http://java.sun.com/javase/downloads/index.jsp


Also note that when you install the JDK, you get a JRE as well, so you may just be looking for the compiler in the wrong place.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42033
    
  64
The JDK contains the Java compiler in a file called javac.exe. Anything that calls itself "Development Kit" on http://java.sun.com/javase/downloads/?intcmp=1281 should have it.


Ping & DNS - my free Android networking tools app
Jyoti Vaskar
Ranch Hand

Joined: Jun 30, 2009
Posts: 142
thanku Henry & Ulf,

Now I have downloaded the right jdk tool.

But now again finding one problem while running javac.exe file.

I have set the path to C:\Program Files\Java\jdk1.6.0_14\bin & restarted the PC.

kindly give me the solution.

thanks.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42033
    
  64
Jyoti Vaskar wrote:But now again finding one problem while running javac.exe file.

What problem is that?
Jyoti Vaskar
Ranch Hand

Joined: Jun 30, 2009
Posts: 142
Ulf Dittmer wrote:
What problem is that?


the javac.exe file is when run blinks & get disappeard.

I have set the classpath to bin .
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42033
    
  64
How are you running it? It sounds as if you're double-clicking it, which is the wrong way to use it. You'd use it from the command line by typing something like "javac MyJavaClass.java".
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14193
    
  20

See Sun's Hello World tutorial to learn how to use the Java compiler (javac.exe) from the command line.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Jyoti Vaskar
Ranch Hand

Joined: Jun 30, 2009
Posts: 142
Ulf Dittmer wrote:How are you running it? It sounds as if you're double-clicking it, which is the wrong way to use it. You'd use it from the command line by typing something like "javac MyJavaClass.java".


I have typed the command as C:\Program Files\Java\jdk1.6.0_14\bin\javac.exe in commandline.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14193
    
  20

If you are running it in a command prompt window like you described, then what do you mean exactly with
the javac.exe file is when run blinks & get disappeard
Jyoti Vaskar
Ranch Hand

Joined: Jun 30, 2009
Posts: 142
Jesper Young wrote:If you are running it in a command prompt window like you described, then what do you mean exactly with
the javac.exe file is when run blinks & get disappeard


sorry for using wrong world.

its run in the start menu, not command prompt.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

Don't run commands that do not have a graphical user interface from the start menu. Start a command prompt instead (it's called "cmd" if you want to use Start -> Run), and then use that for applications like javac.exe and java.exe.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jyoti Vaskar
Ranch Hand

Joined: Jun 30, 2009
Posts: 142
Jyoti Vaskar wrote:
Ulf Dittmer wrote:How are you running it? It sounds as if you're double-clicking it, which is the wrong way to use it. You'd use it from the command line by typing something like "javac MyJavaClass.java".


I have typed the command as C:\Program Files\Java\jdk1.6.0_14\bin\javac.exe in commandline.



I could be able to open it from cmd command prompt !!! thanks

But why cant we open the javac.exe file from the location where the file is stored???
i.e. in C:\Program Files\Java\jdk1.6.0_14\bin ???

or from run in start menu by giving the direct command C:\Program Files\Java\jdk1.6.0_14\bin\javac.exe???

Please explain.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14193
    
  20

As I said above, look at Sun's Hello World tutorial, it explains step by step how to write, compile and run your first Java program after you have installed the JDK.

To open a command prompt window, choose Start / Run..., type in "cmd", and click OK.

Also read the JDK installation instructions, especially point 4 (Update the PATH variable). Note that after changing the PATH variable, you need to close and re-open the command prompt to make it work.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11351
    
  16

as Ulf said, click "start", then "run". type "cmd" into the box, and hit "OK". This will give you a command window (sometimes called a DOS box by us old farts). this is how you used to interact with a computer.

if your path is set up correctly, you should be able to type "javac -version", and it should print something like "javac 1.6.0_11"

if it prints
'javac' is not recognized as an internal or external command,
operable program or batch file.
your path is not correct.

Assuming that works, your next step is to compile your program. Assuming you have a java file names "MyClass.java", you would type

javac MyClass.java

Note: Case is very important here. Even though Windows is not case sensitive, the java compiler is. It will see a difference between "myclass.java" and "MyClass.java". What you type has to match your file name EXACTLY.

this should create a file called "MyClass.class".

If you get that far, come back and we'll try the next step.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Jyoti Vaskar
Ranch Hand

Joined: Jun 30, 2009
Posts: 142
fred rosenberger wrote:as Ulf said, click "start", then "run". type "cmd" into the box, and hit "OK". This will give you a command window (sometimes called a DOS box by us old farts). this is how you used to interact with a computer.

if your path is set up correctly, you should be able to type "javac -version", and it should print something like "javac 1.6.0_11"

if it prints
'javac' is not recognized as an internal or external command,
operable program or batch file.
your path is not correct.

Assuming that works, your next step is to compile your program. Assuming you have a java file names "MyClass.java", you would type

javac MyClass.java

Note: Case is very important here. Even though Windows is not case sensitive, the java compiler is. It will see a difference between "myclass.java" and "MyClass.java". What you type has to match your file name EXACTLY.

this should create a file called "MyClass.class".

If you get that far, come back and we'll try the next step.



thanku Fred.

I could be able to open it from cmd command prompt & know the compiling & running steps now!!!

But want to know why we cant open the javac.exe file from the location where the file is stored???
i.e. in C:\Program Files\Java\jdk1.6.0_14\bin ???

or from run in start menu by giving the direct command C:\Program Files\Java\jdk1.6.0_14\bin\javac.exe???

Please explain if anyone have any idea .
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3602
    
  15
Jyoti Vaskar wrote:But want to know why we cant open the javac.exe file from the location where the file is stored???
i.e. in C:\Program Files\Java\jdk1.6.0_14\bin ???

or from run in start menu by giving the direct command C:\Program Files\Java\jdk1.6.0_14\bin\javac.exe???

Please explain if anyone have any idea .


You can, but unless you pass some parameters to it (such as -version) it doesn't do anything. That is why you saw 'when run blinks & get disappeard'. The program started, found it had nothing to do and so stopped immediately.


Joanne
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11351
    
  16

javac.exe is not a GUI program. it has no buttons, no scroll bars, no images... in the most basic sense, it is a translator. It converts a file of words and symbols (your *.java file) into "bytecode" as a *.class file.

Imagine if I said "translate the following from English to French:"

you'd do nothing, because there is nothing to translate. When you double click on the java.exe icon, that's effectively what you're doing. Your saying "Translate the following file from java to bytecode" - but you didn't tell it a file name. so, Windows starts up a command window, starts the javac program, it does nothing, quits, and then windows closes the command window, since it's not needed anymore.

if you open the command window yourself, you can call whatever program you want, and when it's done, the command window stays open.
Jyoti Vaskar
Ranch Hand

Joined: Jun 30, 2009
Posts: 142

thaku Joanne & Fred for your answers.

I found it very helpful & incresed my knowledge.

thanku Fred for the wonderful explaination .

thanku .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java compiler in java6