A K Kumar wrote:i also have the same problem. i am able to compile my program but could not see it's output. could you please tell me how to see the output of a java program.
Please start a new thread for new questions. When you do, please TellTheDetails, and remember that ItDoesntWorkIsUseless. We have no idea what you're doing, what your program looks like, how you're trying to compile or run it, etc.
Yesterday I was in your situation and I know how much it hurts. Check the notes below which I made for you. If you are able to compile your program, it means you have set your environment variables right. Now its pretty easy to run your program. However I am sending you the complete procedure for compiling and running your program. If you read the entire thread you would have got everything. Anyways I will make it easy for you.
JDK for compilation - C:\Program Files\Java\jdk1.6.0_18\bin
Path of file - C:\Users\Sony\Desktop\java
filename - infinite.java
To compile the application.
First command in Command prompt:-
cd C:\Program Files\Java\jdk1.6.0_18\bin
Next command in command prompt(to compile) being in this directory:-
A .class file gets generated.
To run the file:-
Next command in command prompt:-
Next command in command prompt(to run) being in this directory:-
The above command is java followed by the name of the .class file which is generated.
If your class is a public class the class name and .java file name need to be the same.
If you do not specify public this requirement is ruled out.
Lemme know if you are still facing any problem.
Thanks and Regards, Saumya Purkayastha - Sam
Specialist - Internet Marketing
That procedure, I am afraid, is not very good. You appear to be storing your own files in the installation directory. Don't do that; if you uninstall Java and install a new version, all your work might vanish. follow the installation instructions, including §4 about setting the path. Don't set a classpath at this stage.
Create a "java" (or some other name) directory in "my documents" by entering the following at the command line:
You can create that directory anywhere you wish.
Create and save your .java files with a decent text editor, eg Notepad2, Notepad++, jEdit (I think NotePad is no use for programming).
It tells you in the Java™ Tutorials how to run your very first program.
Joined: Mar 27, 2010
I have not saved my files in the installation directory. I have saved them in a directory called java which I created in the desktop.
Please check the path above. The installation directory is in program files which is required to call the javac compiler.
Joined: Oct 13, 2005
Saumya Purkayastha wrote:Thanks to to all the ppl for replying. . . .
I'm having two similar problems like this fellow is having. Firstly, I'm using the Head First Java 2nd Edition book to learn java, I think that's what the other fellow is using as well. I run Vista 32 bit and have the JDK version 6. I downloaded and installed Java and the book says to modify and/or add a PATH to javac. Right now I can type c:\java\jdk1.60_20\bin\javac to compile my .java files but i would like to be able to just type javac or the % javac like stated in the book.
I Also cannot run the MyFirstApp.class program from the book.
this is the code the book tells to write:
This is what I get from the C:\ prompt:
I also tried and ran the "HelloWorldApp" from the java website tutorial the code was like this:
The HelloWorldApp file ran just fine when I typed java HelloWorldApp.class into the C:\ prompt. I put the codes side by side and can't find anything different, so I'm not sure what the problem is. Any ideas?