This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
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: 35443
9
posted
0
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
posted
0
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: 35443
9
posted
0
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".
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.
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.
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???
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.
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.
Never ascribe to malice that which can be adequately explained by stupidity.
Jyoti Vaskar
Ranch Hand
Joined: Jun 30, 2009
Posts: 142
posted
0
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???
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.
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.