So I am learning Java and and I know basic procedural coding. I am getting to object-oriented. I am using this book called Head First Java. I just made a practice program but the thing is I do not know how to compile and run it. I only have one class and the class' name is Application so I named the file Application.java
I am using this text-editor called Notepad++.
How do I compile and run Java source code files.
Faraz Bukhari wrote:I really feel like I have because I started doing it with these other online tutorials and now I am using Head First Java so I think I have a JDK. How do I check?
Don't know what you mean by "feel like" you have. Either you did, or you didn't... software doesn't get accidentally download and installed (well, those that isn't malware that is).
The java compiler (which is used to compile java programs) is named "javac" and the JVM (which is used to run java programs) is named "java". What happens when you type either of these on the command line?
Joined: Jul 27, 2013
When I type in javac it is not recognized as an internal or external command. When I type in Java it comes up with a list of commands or something.
Yes. And the link which Henry posted does explain how to deal with that. In the section headed "Setting the JAVA_HOME and PATH environment variables".
This all may seem rather obscure and picky. Which it is, really. But back when Java was first invented it was mainly used by people who were already programmers and who were familiar with folders and paths and other low-level operating system stuff, so they wouldn't have had any trouble with it. Nowadays Java is being installed by people who haven't had that kind of experience, though, and it's a lot more of a headache.
Once you successfully set JAVA_HOME environment variable [Tutorial] using cmd tool of windows, go to the directory where your java files are located. type "javac Application.java" to compile your java code. It will produce a "class" file within the same directory named as "Application.class". Now you can run your java program using the command "java Application". Hope it helps