This is the code of Interface.java I'm executing the code by following commands:
command: javac InterfaceDemo.java
I'm getting successful compilation and getting the class files.
command: java InterfaceDemo
but after running the above command I'm getting the error like Could not load or find main class InterfaceDemo
package pkg1;
import java.io.*;
interface MyInter
{
void connect();
void disconnect();
}
class OracleDB implements MyInter
{
@Override
public void connect() {
System.out.println("Connecting To oracle Database...");
}
@Override
public void disconnect() {
System.out.println("Database operations on oracle DB Completed.");
System.out.println("Disconnecting from oracle Database... ");
}
}
class SybaseDB implements MyInter
{
@Override
public void connect() {
System.out.println("Connecting To sybase Database...");
}
@Override
public void disconnect() {
System.out.println("Database operations on sybase DB Completed.");
System.out.println("Disconnecting from Sybase Database... ");
}
}
public class InterfaceDemo {
public static void main(String[] args) throws Exception {
Class c = Class.forName(args[0]);
MyInter mi=(MyInter)c.newInstance();
mi.connect();
mi.disconnect();
}
}