• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem trying to compile Java Program

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 2236
63
IntelliJ IDE Firefox Browser Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
If tomatoes are a fruit, then ketchup must be a jam. Taste this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic