SET AS HOME PAGE

ADD TO FAVORITES / BOOKMARK THIS WEBSITE (More Details)

Introduction

Servlet

Jsp

Security

Enterprise Beans

Contact Us


Compiling Java programs in command prompt

 Introduction

Java is an object-oriented programming language with a built-in application programming interface (API) that can handle graphics and user interfaces and that can be used to create applications or applets. Because of its rich set of API's, similar to Macintosh and Windows, and its platform independence, Java can also be thought of as a platform in itself. Java also has standard libraries for doing mathematics.

You need to download Jdk or j2sdk and instal it in your system. Next you need to set the JDK path as explained below topic (Clear Details about how to Set the JDK path)


 Steps to compile java programs in Command Prompt

  1. Any where you can save your java files and compile it. For, example let us create java files in c:\Franklin\prg1.
    For this, first open the c: drive

    Now let us create a folder Franklin in c: drive.

    Now open the folder Franklin and again create another folder prg1 inside the folder C:\Franklin\
  2. Now open the folder prg1 and put the .java files inside the folder C:\Franklin\prg1\.
    For example, put Sample1.java inside the folder C:\Franklin\prg1\
  3. Now you need to open the command prompt. To open the command prompt goto start->Run and click it
  4. Now a Run dialog box will open.

    Now type cmd in the open text box

    Now click the OK button
  5. Now a Command Prompt will open
  6. Now type cd C:\Franklin\prg1 in the command prompt
  7. Now compail the java files.
    You can compile all the java files inside this folder C:\Franklin\prg1\, simply typing javac *.java
    (OR)
    To compile java files one by one. Here, type the file name like javac Sample1.java
  8. Now the java Sample1.class file will be create in the folder C:\Franklin\prg1\
  9. Program compiled successfully
  10. If you need to run JDK java programs and swings using command prompt, then you can run simply by typing java Sample1 in the command prompt
    If you need to run Applet programs then you can run by typing appletviewer Sample2.java in the command prompt
    Note: You cannot run java server programs in command prompt. You need server and Browser


 Click To Go Back
<- BACK