• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem trying to compile Java Program  RSS feed

 
Paul Wyatt
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
Im completely new to Java but I have experience with other programing and command entry. I followed some instructions to install the JDK and create the basic HelloWorld compiled program.
On my Vista system, I added a path extension to the system environmental variables (C:\Program Files\Java\jdk1.8.0\bin). I created my HelloWorld.java source as below, and used the javac <filename> command to compile it.
This completed without complaint when I entered the javac command whilst in th C:/ directory, and entered the full path to the source.
However Java didn't create a HelloWorld.class file. What did I do wrong or overlook ? Here is the source file, created from the instructions provided:

public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World.");
}
}

Any help would be appreciated.
 
Paweł Baczyński
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In which directory is your source file?

I created a file like yours as C:\directory\HelloWorld.java
While in C:\ in command line I typed javac C:\directory\HelloWorld.java
The class file was created: C:\directory\HelloWorld.class
It will not be created in your current directory.
 
Paul Wyatt
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pawel
I must have made a mistake somewhere without realising.
I repeated the compile as you laid out and its worked OK this time.

Thanks for your help with this.

Paul
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!