Showing posts with label example. Show all posts
Showing posts with label example. Show all posts
Different between java v/s javac v/s javacpl vs. javaw

Different between java v/s javac v/s javacpl vs. javaw

javacpl.cpl :

  • javacpl.cpl is a java controll panel belonging to an java(TM) Platform SE 6 U5 from Sun Microsystems, Inc.
  • Non-system processes like javacpl.cpl originate from software you installed on your system. 
  • Since most applications store data in your system's registry.
  • To stop javacpl.cpl permanently uninstall 'Java(TM) Platform SE 6 U5' from your system.

javac :

  • javac is a compiler program. it compiles java source program [ .java ] into bytecode class file [ .class ]
  • To use javac you need to add java bin directory path in your system variable.
  • javac is inside the JDK_HOME/bin in java directory in windows.
  • How to compile java source program follow the steps.
  1. First if you don`t set Environment path then setup. and open "command prompt".
  2. press  [ windows key + R ] and type [ cmd ].
  3. Now, write javac filename.java

javaw :


  • javaw.exe is located in bin directory.
  • javaw.exe is very similar to java.exe. It can be considered as a parallel twin. It is a Win32 GUI application.
  • his is provided as a helper so that application launches its own GUI window and will not launch a console. Whenever we want to run a GUI based application and don’t require a command console, we can use this as application launcher. Eclipse is used javaw.exe.

import javax.swing.*;

public class HelloWorldSwing {
    private static void createAndShowGUI() {
        JFrame jFrame = new JFrame("HelloWorld Swing");
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JLabel helloLabel = new JLabel("Hello World!");
        jFrame.getContentPane().add(helloLabel);
        jFrame.pack();
        jFrame.setVisible(true);
    }

    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }
}

  • We can execute the above GUI application using both java.exe and javaw.exe If we launch using java.exe, the command-line waits for the application response till it closes. When launched using javaw, the application launches and the command line exits immediately and ready for next command

Difference between abstract class and interface

Difference between abstract class and interface


Abstract Class Interface
Abstract class can have abstract and non-abstract methods. Interface can have only abstract methods.
Abstract class can have constructor. Interface can not have constructor.
Abstract class doesn't support multiple inheritance. Interface supports multiple inheritance.
The abstract keyword is used to declare abstract class. The interface keyword is used to declare interface.
Abstract class can have final, non-final, static and non-static variables. Interface has only static and final variables.
Abstract class can provide the implementation of interface. Interface can't provide the implementation of abstract class.
Calendar class is example of abstract class. ActionListener is example of interface.
Example:
 public abstract class Shape{
  public abstract void draw();
 }
Example:
 public interface Drawable{
  void draw();
 }

Example of abstract class and interface in Java

 // abstract class
 
 abstract class A{
  abstract void display();
 }

 // interface
 interface C{
  
  void test();
  void disp();
  
 }

 // class B that extends A and implements C
 
 class B extends A implements C{
  public static void main(String... str){
   B b=new B();
   
   // call interface methods
   
   b.disp();
   b.test();
   
   // call abstract class method
   
   b.display();
  }
  
  public void test(){
   System.out.println("test method.");
  }
  
  public void disp(){
   System.out.println("Disp method.");
  }
  public void display(){
   System.out.println("Display method.");
  }
 }