Breaking

Search This Blog

Saturday 11 August 2018

Hello : How to Create Your First Java Program

Hello : How to Create Your First Java Program


It's a First Program Of Java⬇

class Suryansh
{
public static void main(String a[])
{
System.out.println("hello");
}
}



format of save the java program & Important points

  format:  classname.java

{ first letter of class name is always capital } 
{class name and file name is always same }
ex: Suryansh.java,Technical.java

Save this file on C, D,E,F etc drive . before run the java program first set the Environment path .

 OutPut


Compile the Program

we will use the javac command[CMD] to convert your Java program into a form more amenable for execution on a computer.

  • first open CMD
    C:\Users\username>d: {drive name}
    D:\>cd java {folder name when program is saved} 
  • Assuming the file, say  Suryansh.java, is in the current working directory, type the javac command give space and your program name.
D:\java>javac Suryansh.java 
  • write our java & our program name with out ".java" 

If everything went well, you should see no error messages.
    Execute the Program
    You will use the java command to execute your program.
    • From the Command Prompt, type the java command below.
      D:\java>java Suryansh
      
      Hello
      If all goes well, you should see the output of the program - Hello



    No comments:

    Post a Comment

    '; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();