Executing java inside java example program

Executing java inside java:

MyJava.java

class MyJava{
	
	public static void main(String[] args){
	Javadomain jd = new Javadomain();
	jd.main(null);
}

}

Now we are going to execute this below java program(Javadomain.java) inside the above the java program(MyJava.java),

Javadomain.java:

class Javadomain{
	public static void main(String[] args){
		System.out.println("I am executed successfully, Java inside java success");
	}
}

Output:

I am executed successfully, Java inside java success

Note:
Ensure you have both the above java programs in the same path.

93 total views, 1 views today

Leave a Reply

Your email address will not be published. Required fields are marked *