• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

java compiler in java6

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
author
Posts: 23959
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jyoti Vaskar
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jyoti Vaskar wrote:But now again finding one problem while running javac.exe file.


What problem is that?
 
Jyoti Vaskar
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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".
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See Sun's Hello World tutorial to learn how to use the Java compiler (javac.exe) from the command line.
 
Jyoti Vaskar
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Sheriff
Posts: 22849
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jyoti Vaskar
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jyoti Vaskar
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 .
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
fred rosenberger
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

thaku Joanne & Fred for your answers.

I found it very helpful & incresed my knowledge.

thanku Fred for the wonderful explaination .

thanku .
 
reply
    Bookmark Topic Watch Topic
  • New Topic