Free java decompiler

This is one of java decompiler that can be use to get java source file (file with .java as it's file extension) from any java class file (file with .class as it's file extension). Class file is a result after compiling process success without any syntax error.

Click link below to download

1. JD-GUI




2. Cavaj Java Decompiler


3. JCavaj Java Decompiler

Java get binary value from alphabet

Today, i have learned about how to get binary value from alphabet. You can try compile and execute java program below to get all binary value for A-Z and a-z.


*********************************************************************
COMPLETE SOURCE CODE FOR : JavaGetBinaryFromLetter.java
*********************************************************************


public class JavaGetBinaryFromLetter
{
public static void main(String[]args)
{
String a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

for(int i=0;i<a.length();i++)
{
char b=a.charAt(i);
int temp=(int)b;
String c=Integer.toBinaryString(temp);
System.out.println("BINARY VALUE FOR LETTER "+b+" IS : "+c);
}
}
}


*********************************************************************
JUST COMPILE AND EXECUTE IT
*********************************************************************

Java ternary operator

Today i have learned about ternary operator in java. Before this, when i found it in java code, i will ask myself what it is and what we call it...now i will share with you what i understand about ternary operator.Now, see java code below


************************************************************
COMPLETE SOURCE CODE FOR : JavaTernaryOperator.java
************************************************************


public class JavaTernaryOperator
{
public static void main(String[]args)
{
int a=0;
int b=4;
int c=5;

//THIS IS EXAMPLE OF TERNARY OPERATOR
a=(b>c?b:c);

System.out.println(a);
}
}


************************************************************
JUST COMPILE AND EXECUTE IT
************************************************************

In the java code above, example of ternary operator is a=(b>c?b:c);.So, what it mean ?

This is the answer :
Value a is equal to b if b larger than c or value a is equal to c if b smaller than c.So, java code above has same meaning with java code below.


public class JavaTernaryOperator
{
public static void main(String[]args)
{
int a=0;
int b=4;
int c=5;

if(b>c)
{
a=b;
}
else
{
a=c;
}

System.out.println(a);
}
}


Now, you can choose which one you want to use when write your java program. It seem when we use ternary operator we can make our program more shorter.

Java hexadecimal to binary

Complete source code below is a simple java program that can be use to get binary value from hexadecimal value.

******************************************************************
COMPLETE SOURCE CODE FOR : JavaHexToBin.java
******************************************************************


import java.util.Scanner;

public class JavaHexToBin
{
public static void main(String[]args)
{
String[]hex={"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"};
String[]binary={"0000","0001","0010","0011","0100","0101","0110","0111","1000","1001","1010","1011","1100","1101","1110","1111"};

Scanner s=new Scanner(System.in);
System.out.print("Put hex value : ");
String userInput=s.next();
String result="";
for(int i=0;i<userInput.length();i++)
{
char temp=userInput.charAt(i);
String temp2=""+temp+"";
for(int j=0;j<hex.length;j++)
{
if(temp2.equalsIgnoreCase(hex[j]))
{
result=result+binary[j];
}
}
}
System.out.println("IT'S BINARY IS : "+result);
}
}


******************************************************************
JUST COMPILE AND EXECUTE IT
******************************************************************

Java determine pixel was clicked or not

Complete source code below just a simple java program that will determine if you was clicked or not on 8 black dots. If you was clicked , program will inform you that the dot was clicked.I hope you can see all 8 black dots that i mean because it is too small and try click on it to see what happen.

***************************************************************************
COMPLETE SOURCE CODE FOR : JavaDeterminePixelClicked.java
***************************************************************************


import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class JavaDeterminePixelClicked extends Canvas implements MouseListener
{
boolean [] con={ false,false,false,false,false,false,false,false };
int[][]coor=new int[8][2];
Robot r;

public JavaDeterminePixelClicked()
{
addMouseListener(this);
try
{
r=new Robot();
}
catch(Exception exception)
{
exception.printStackTrace();
}

JFrame a=new JFrame(">>>>>TRY CLICK AT BLACK DOT<<<<<");
a.getContentPane().add(this,BorderLayout.CENTER);
a.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
a.setSize(500,500);
a.setLocationRelativeTo(null);
a.setVisible(true);
}

public void paint(Graphics g)
{
setBackground( new Color (255,255,255) );
super.paint(g);
g.setColor( new Color (0,0,0) );
g.drawLine(30,30,30,30);
g.drawLine(40,40,40,40);
g.drawLine(50,50,50,50);
g.drawLine(60,60,60,60);
g.drawLine(70,70,70,70);
g.drawLine(80,80,80,80);
g.drawLine(90,90,90,90);
g.drawLine(100,100,100,100);
}

public void mouseClicked(MouseEvent event)
{
Color temp=r.getPixelColor(event.getLocationOnScreen().x,event.getLocationOnScreen().y);
if(temp.getRed()==0&&temp.getGreen()==0&&temp.getBlue()==0)
{
int upperLeftX=getLocationOnScreen().x;
int upperLeftY=getLocationOnScreen().y;
int currentX=event.getLocationOnScreen().x;
int currentY=event.getLocationOnScreen().y;
if(currentX-upperLeftX==30&¤tY-upperLeftY==30)
{
if(con[0]==false)
{
con[0]=true;
}
else
{
JOptionPane.showMessageDialog(null,"This point was clicked");
}
}
if(currentX-upperLeftX==40&¤tY-upperLeftY==40)
{
if(con[1]==false)
{
con[1]=true;
}
else
{
JOptionPane.showMessageDialog(null,"This point was clicked");
}
}
if(currentX-upperLeftX==50&¤tY-upperLeftY==50)
{
if(con[2]==false)
{
con[2]=true;
}
else
{
JOptionPane.showMessageDialog(null,"This point was clicked");
}
}
if(currentX-upperLeftX==60&¤tY-upperLeftY==60)
{
if(con[3]==false)
{
con[3]=true;
}
else
{
JOptionPane.showMessageDialog(null,"This point was clicked");
}
}
if(currentX-upperLeftX==70&¤tY-upperLeftY==70)
{
if(con[4]==false)
{
con[4]=true;
}
else
{
JOptionPane.showMessageDialog(null,"This point was clicked");
}
}
if(currentX-upperLeftX==80&¤tY-upperLeftY==80)
{
if(con[5]==false)
{
con[5]=true;
}
else
{
JOptionPane.showMessageDialog(null,"This point was clicked");
}
}
if(currentX-upperLeftX==90&¤tY-upperLeftY==90)
{
if(con[6]==false)
{
con[6]=true;
}
else
{
JOptionPane.showMessageDialog(null,"This point was clicked");
}
}
if(currentX-upperLeftX==100&¤tY-upperLeftY==100)
{
if(con[7]==false)
{
con[7]=true;
}
else
{
JOptionPane.showMessageDialog(null,"This point was clicked");
}
}
}
}

public void mouseEntered(MouseEvent event)
{
//NOTHING
}

public void mouseExited(MouseEvent event)
{
//NOTHING
}

public void mousePressed(MouseEvent event)
{
//NOTHING
}

public void mouseReleased(MouseEvent event)
{
//NOTHING
}

public static void main(String[]args)
{
JavaDeterminePixelClicked jdpc = new JavaDeterminePixelClicked ();
}
}


***************************************************************************
JUST COMPILE AND EXECUTE IT
***************************************************************************

Java get degree from radian

Complete source code below just a simple java program that we can use to get degree value from radian value.

*****************************************************************
COMPLETE SOURCE CODE FOR : GetDegreeFromRadian.java
*****************************************************************


public class GetDegreeFromRadian
{
public static void main(String[]args)
{
//CHANGE RADIAN VALUE TO WHAT VALUE THAT YOU WANT
double radian=1.00;

//PRINT ANGLE VALUE THAT WE GET FROM RADIAN
System.out.println( "IT'S ANGLE IS : " + radian* (180/Math.PI) );
}
}


*****************************************************************
JUST COMPILE AND EXECUTE IT
*****************************************************************

Java receive user input and sort it in ascending order

Complete source code below is a simple java program that will receive user input and after that sort it in ascending order before display it's result.

*********************************************************************
COMPLETE SOURCE CODE FOR : AscendingString.java
*********************************************************************


import java.util.Scanner;

public class AscendingString
{
public static void main(String[]args)
{
Scanner s=new Scanner(System.in);
String[]a=new String[5];
for(int i=0;i<5;i++)
{
System.out.println(i+1+".Put your String");
String temp=s.nextLine();
a[i]=temp;
}

System.out.println("**********");
System.out.println("RESULT");
System.out.println("**********");

for(int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{
String temp=a[i];
String tempB=a[j];
if(temp.compareTo(tempB)<0)
{
a[i]=tempB;
a[j]=temp;
}
}
}

for(int i=0;i<5;i++)
{
System.out.println(a[i]);
}
}
}


*********************************************************************
JUST COMPILE AND EXECUTE IT
*********************************************************************

Java recursive method

Sometime we need to solve a problem using the same way. For example you need to build a program that will print number from 1 until number that input by a user. First program will print number without using recursive technique and second program we will use recursive technique to print number from 1 until number that input by a user.You should see how a recursive method will do the same thing until problem solve.

FIRST PROGRAM :


import java.util.Scanner;

public class Test
{
public static void main(String[]args)
{
Scanner s=new Scanner(System.in);
System.out.println("Put a number");
int a=s.nextInt();

System.out.println("IT'S RESULT");
System.out.println("***************");

for(int i=1;i<=a;i++)
{
System.out.println(i);
}
}
}


SECOND PROGRAM :
print method in PrintNumber class is example of recursive method.


import java.util.Scanner;

public class Test
{
public static void main(String[]args)
{
Scanner s=new Scanner(System.in);
System.out.println("Put a number");
int myNumber=s.nextInt();
PrintNumber pn=new PrintNumber();
System.out.println("IT'S RESULT");
System.out.println("***************");
pn.print(myNumber);
}
}

class PrintNumber
{
public void print(int a)
{
if(a==1)
{
System.out.println(a);
}
else
{
int temp=a-1;
print(temp);
System.out.println(a);
}
}
}


For example if you put 2 into second program, when it enter print method in PrintNumber class, firstly program will check if the number is 1 or not. If not, the number will be minus with 1 before it send it's result to print method again. In this case it will send 1 to print method. So System.out.println(a) for a=2 will stop for a while until a=1. Now after it send 1 to print method, condition for a==1 will be true. 1 will be print, and System.out.println(a) for a=2 will continue again by print 2.

I hope it will help.

Set JOptionPane background color

After i make some review over internet and java forum lastly i understand how to change JOptionPane background color.You can try compile and execute simple code below and see it's result.

***************************************************************
COMPLETE SOURCE CODE FOR : SetJOptionPaneBackgroundColor.java
***************************************************************

import javax.swing.JOptionPane;
import javax.swing.UIManager;

import javax.swing.plaf.ColorUIResource;

public class SetJOptionPaneBackgroundColor
{
public static void main(String[]args)
{
UIManager uim=new UIManager();
uim.put("OptionPane.background",new ColorUIResource(255,0,0));
uim.put("Panel.background",new ColorUIResource(255,0,0));

JOptionPane.showMessageDialog(null,"Hello world","HELLO WORLD",JOptionPane.INFORMATION_MESSAGE);
}
}

***************************************************************
JUST COMPILE AND EXECUTE IT
***************************************************************

Java count all white space in String

Yesterday, before i go to sleep i tried to answer a simple question from a site. The question is about how to count all white space from String that input by a user. After a few time i failed, i found code below :

*********************************************************
COMPLETE SOURCE CODE FOR : CountAllWhitespaceInString.java
*********************************************************


import java.util.Scanner;

public class CountAllWhitespaceInString
{
public static void main(String[]args)
{
boolean a=true;
Scanner sc=new Scanner(System.in);

while(a)
{
System.out.println("Type EXIT to exit");
String b=sc.nextLine();
int whitespaceNumber=0;

if(!b.equalsIgnoreCase("exit"))
{
try
{
for(int i=0;i<=b.length()-1;i++)
{
char temp=b.charAt(i);
if(temp==' ')
{
whitespaceNumber++;
}
}
System.out.println("Whitespace number is : "+whitespaceNumber);
}
catch(Exception exception)
{
System.out.println("DON'T DO THAT");
}
}
else
{
a=false;
}
}
}
}


*********************************************************
JUST COMPILE AND EXECUTE IT
*********************************************************

Java reverse String and simplest palindrome checker

Today, i have learn something new and it's totally simple. Sometime when don't know about that, we will use our way that take a time to complete a simple task. What i learn today is, how to reverse String. The easiest way to reverse a String for example from "i love you" to "uoy evol i" is using method reverse() in StringBuffer class. It is also very useful especially when you want to create a palindrome checker program. Your program will be the shortest palindrome checker program in the world i think, hehehehe. I have also created a new one before, but it quit long. You can review it by click here. Now we will go to coding part. I will create two simple programs. Firstly to reverse "i love you" to "uoy evol i". Secondly i will create my shortest palindrome checker program that i ever made. Don't waste our time by hear what i said.

*************************************************************
COMPLETE SOURCE CODE FOR : ReverseString.java
*************************************************************


public class ReverseString
{
public static void main(String[]args)
{
String a="i love you";
StringBuffer b=new StringBuffer(a);

System.out.println(b.reverse());
}
}


*************************************************************
LIKE USUAL, JUST COMPILE AND EXECUTE IT
*************************************************************

*************************************************************
COMPLETE SOURCE CODE FOR : MySimplestPalindromeChecker.java
*************************************************************


import javax.swing.JOptionPane;

public class MySimplestPalindromeChecker
{
public static void main(String[]args)
{
String a=JOptionPane.showInputDialog(null,"What word that you want to check ?","Palindrome Checker",JOptionPane.QUESTION_MESSAGE);

if(a!=null)
{
String b=a;
StringBuffer c=new StringBuffer(b);
if(a.equals(c.reverse().toString()))
{
JOptionPane.showMessageDialog(null,"THIS IS A PALINDROME WORD");
}
else
{
JOptionPane.showMessageDialog(null,"THIS IS NOT A PALINDROME WORD");
}
}
}
}


*************************************************************
JUST COMPILE AND EXECUTE IT
*************************************************************

Square root symbol in java

After i spend a day to find how to print square root symbol in java through command prompt, someone tell me from java forum if our command prompt did not have a glyph for the square root character, this job will undone. But when i try use it in JOptionPane's message box it perform well.

In java "\u221A" is refer to square root symbol. It is Unicode.You can try to visit link below for more details :
Click here

If you want to print square root symbol through your command prompt, you can try something like this. I hope your command prompt can support for this thing.


public class Test2
{
public static void main(String[]args)
{
System.out.println("\u221A");
}
}


If you want to put it in JOptionPane's message box (this is perform well in my computer), you can try this :


import javax.swing.JOptionPane;

public class Test2
{
public static void main(String[]args)
{
JOptionPane.showMessageDialog(null,"\u221A");
}
}

RELAXING NATURE VIDEO