• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

how to run a java file after writing and saving

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
class apple{
public static void main (srting [] args){
system.out.println("Duck");
}
}


 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read http://download.oracle.com/javase/tutorial/getStarted/cupojava/win32.html
 
Ranch Hand
Posts: 36
jQuery Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
open the command line.

change directory to where the java file is located.

1.type in:

javac apple.java

2. You'll notice, there is a file create with the .class extension, in this case, apple.class

3. then finally, run the class file by typing in:

java apple

4. Notice that there is no extension.
 
Ranch Hand
Posts: 87
Android Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jelo Nehuptra is right, but make sure that you have installed jdk & you need to configure environment variables if you are using windows.
classpath & path you need to be set to run javac or java command on command prompt. Rest is explained by Jelo Nehuptra.
 
If somebody says you look familiar, tell them you are in porn. Or in these tiny ads:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic