Create Amezing animation with JAVA In CMD


Hello Friend, JAVA is a simple language to create application also provide the best preformation due to a feature of multi-threading using that feature user can control Thread. Using this feature we develop animation creativity base on sleep the thread and it develops in java console so using special create various shape and using loop concept and process builder for run cmd command through java.

If you don’t know about Multi-threading: https://www.javatpoint.com/multithreading-in-java
Sleep tread: https://www.tutorialspoint.com/java/lang/thread_sleep_millis.html
Loop concept: http://www.geeksforgeeks.org/loops-in-java/
Process Builder: http://www.xyzws.com/javafaq/how-to-run-external-programs-by-using-java-processbuilder-class/189

 Animation part 1:

                                            #Program 1:

 
class Ex extends Thread
{
 int flag=0;
 Ex()
 {
  start();
 }
 public void run()
 {
 int i=0;
 try
 {
  while(i<200)
  {
   if(flag==0)
   {
    System.out.print("/");
    flag=1;
    Thread.sleep(100);
   
   }
   else if(flag==1)
   {
    System.out.print("-");
    flag=10;
    Thread.sleep(100);
   }
   else
   {
    System.out.print("\\");
    flag=0;
    Thread.sleep(100);
   }
   new ProcessBuilder("cmd", "/c", "cls").inheritIO().start

().waitFor();
   i++;
  }
 }
 catch(Exception e)
 {}
   
 }
 public static void main(String a[]) throws Exception 
 {
  Ex e=new Ex(); 
 }
Output: loading animation

Loading animation (Sorry this is not proper output for proper output check youtube video by click here)

                                            #Program 2:

Animation of three line in which one line crossing from one line to other and line is not a normal line it like / / \ and change color at a certain time.                                                                                                                                            \ / /
 class Ex extends Thread
{
Ex()
{
 start();
}
public void run()
{
 int i=0;
 int j=0;
 int c=0;
 Boolean b=true;
  try{
  while(i<50)
   {
    new ProcessBuilder("cmd", "/c", "color "+c).inheritIO

().start ().waitFor(); 
    c++;
    if(c==8) c=0;
    i++;
    spaces(40);
    b=aniprint(b,37);
    spaces(j);
    aniprint(b,0);
    j++;
   }
   }catch(Exception e){}
 }
 public void spaces(int n)
 {
  for(int i=0;i<n;i++)
  System.out.print(" ");
 }
 public boolean aniprint(Boolean b,int sp) throws Exception
 {
  if(b==true)
   {
    spaces(sp);
    System.out.println("/ /\\");
    spaces(sp); 
    System.out.println("\\/ /");
    Thread.sleep(25);
    return false;
   }
   else
   {
    spaces(sp);
    System.out.println("/\\ \\");
    spaces(sp);
    System.out.println("\\ \\/");
    Thread.sleep(25);
    return true;
   }
 }
 public static void main(String s[])
 {
  Ex e=new Ex();
 }
}
 

Cross Animation

Output: need to show youtube video by click here.

                                            #Program 3:

This animation is awesome, this looking amazing in this animation also impressive. For output, you need show YouTube video.

 
class Ex extends Thread
{
 Ex()
 {
  start();
 }
 public void run()
 {
  int i=0;
  Boolean b=true;
  Boolean b1=true;
  int c=0;
  int sp=40;
 try{
  while(i<50)
  {
   i++;
  // spaces(sp);
   new ProcessBuilder("cmd", "/c", "color "+c).inheritIO().start().waitFor(); 
   c++;
   if(c==8) c=0;
   b=aniprint(b,sp,sp);
  }
  new ProcessBuilder("cmd", "/c", "color 8f").inheritIO().start().waitFor(); 
  nprintchar("_",80);
  System.out.println();
  i=0;
  int z=40;
  int k=40;
  while(i<40)
  {
   new ProcessBuilder("cmd", "/c", "color "+c).inheritIO().start().waitFor(); 
   c++;
   i++;
   if(c==8) c=0;
   
   b=aniprint(b,--z,++k);   
  }
  i=0;
  while(i<40)
  {
   new ProcessBuilder("cmd", "/c", "color "+c).inheritIO().start().waitFor(); 
   c++;
   i++;
   if(c==8) c=0;
   b=aniprint(b,++z,--k); 
  }
  i=0;
  while(i<40)
  {
   new ProcessBuilder("cmd", "/c", "color "+c).inheritIO().start().waitFor(); 
   c++;
   i++;
   if(c==8) c=0;
   b=aniprint(b,--z,++k,40); 
  }
  i=0;
  while(i<40)
  {
   new ProcessBuilder("cmd", "/c", "color "+c).inheritIO().start().waitFor(); 
   c++;
   i++;
   if(c==8) c=0;
   b=aniprint(b,++z,--k,40); 
  } 
  i=0;
  String s="Thank You for watching ,Devoped By AP(arpit & pradip)";
  while(i<s.length())
  {
   new ProcessBuilder("cmd", "/c", "color "+c).inheritIO().start().waitFor(); 
   c++;
   i++;
   
   System.out.print(s.substring(i,i+1));
   Thread.sleep(200);
  } 
 
 }catch(Exception e){System.out.print(e);}
 } 

 public void spaces(int n)
 {
  for(int i=0;i<n;i++)
  {
   System.out.print(" ");
  }
 }
 public void nprintchar(String s,int n)
 {
  for(int i=0;i<n;i++)
  {
   System.out.print(s);
  } 
 }
 
 public boolean aniprint(Boolean b,int sp1,int sp2) throws Exception
 {
  if(b==true)
   {
    spaces(sp1);
    System.out.println("/ /\\");
    spaces(sp1); 
    System.out.println("\\/ /");
    Thread.sleep(25);
    return false;
   }
   else
   {
    spaces(sp2);
    System.out.println("/\\ \\");
    spaces(sp2);
    System.out.println("\\ \\/");
    Thread.sleep(25);
    return true;
   }
 }
 
 public boolean aniprint(Boolean b,int sp1,int sp2,int sp) throws Exception
 {
  if(b==true)
   {
    spaces(sp);
    System.out.println("/ /\\");
    spaces(sp1); 
    System.out.println("\\/ /");
    Thread.sleep(25);
    return false;
   }
   else
   {
    spaces(sp);
    System.out.println("/\\ \\");
    spaces(sp2);
    System.out.println("\\ \\/");
    Thread.sleep(25);
    return true;
   }
 }   

 public static void main(String a[])
 {
  Ex e=new Ex();

 }
}

OUTPUT: I think you should be show output of this program by click here.

Thank You, if any doubt than comments we try to solve... // ]]>

Download code

Comments

Popular Posts