1

Java : How to create java Source file , Byte Code and execute the program

java Programming

 

To know how to make java source file and execute that created file we take an example of java program.

Question : WAP in java to print “Hello World”.

Step 1 : Open Any file editor like “Notpad or Wordpad “.

Write this code to print “Hello Word”

After you’ve finished typing in the program, save the file somewhere on your disk with the name HelloWorld.java. This is very important. Java source files must have the same name as the class they define (including the same upper- and lowercase letters) and they must have the extension .java.

Here, the class definition has the name HelloWorld, so the filename must be HelloWorld.java. If you name your file something else (even something like helloworld.java or Helloworld.java), you won’t be able to compile it. Make absolutely certain the name is HelloWorld.java.

Compiling and Running the Source File :

From inside DOS, change directories to the location where you’ve saved your HelloWorld.java file. I put mine into the directory CodingTalks, so to change directories I’d use this command:

Once you’ve changed to the right directory, use the javac command as follows, with the name of the file as you saved it in Windows (javac stands for Java compiler). Note that you have to make sure you type all the same upper- and lowercase here as well:

Once you have a class file, you can run that file using the Java bytecode interpreter. The Java interpreter is called simply java, and you run it from the DOS shell as you did javac. Run your Hello World program like this from the command line, with all the same upper- and lowercase (and note that the argument to the java program does not have a .class extension):

If your program was typed and compiled correctly, you should get the phrase Hello World! printed to your screen as a response.

Remember :  the Java compiler and the Java interpreter are different things. You use the Java compiler (javac) for your Java source files to create .class files, and you use the Java interpreter (java) to actually run your class files.



You Need "Java : How to create java Source file , Byte Code and execute the program" ???


"Java : How to create java Source file , Byte Code and execute the program" (Source Code / Report / PPT) Totally belong to CodingTalks Team and We always ready to Share our Stuff with our users. If you are Very Much Interested on This Topic Then you must Leave a Comment what Exactly you Looking For Or Send us Email to get Full Information.

Coding Talks
Team

Filed in: Java Tags: , , , ,

Get Updates

Share This Post

Related Posts

One Response to "Java : How to create java Source file , Byte Code and execute the program"

Leave a Reply

Submit Comment

© 2017 CodingTalks. All rights reserved.

Warning: filemtime(): stat failed for /home/codingtalks/public_html/wp-content/plugins/floating-social-share-bar//js/waypoints.min.js in /home/codingtalks/public_html/wp-content/plugins/floating-social-share-bar/floatingshare.php on line 213