Thursday, March 26, 2015

Apache Tomcat has this error, "java.net.BindException: Address already in use"

This means that another program has already bind to those ports that Tomcat uses.
Your options are:
  1. Change the ports of your Apache Tomcat by editing the ${TOMCAT_HOME}/conf/server.xml.
  2. Shutting down the other program that has bind those ports.
To find and shutdown the other program do the following:
For windows:
  1. Open a command line.
  2. Then type "netstat -nao".
  3. Look for those port numbers, and remember the PID number.
  4. Open task manager.
  5. Find the corresponding PID and end those task(s).
For Linux:
  1. Open a command line.
  2. Then type "netstat -nap".
  3. Look for those port numbers, and remember the PID number.
  4. In the command line type "kill -9 ${PID}" with the PID number.

Tuesday, March 17, 2015

Java setAccessible Method

Can you access a method, or field that isn't accessible? YES, you can.
(You can't declare a class that isn't accessible)
Using the setAccessible method you can access any method or field.


package access;

/**

 @author 
 */
public class A{
 private String message="Hello";

 private String getMessage(){
  return message;
 }
}


package access;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

/**

 @author
 */
public class AccessTest{

 /**
  @param args the command line arguments
  */
 public static void main(String[] args)
  throws Exception{
  A a=new A();

  Method method=a.getClass().getDeclaredMethod("getMessage",new Class[]{});
  method.setAccessible(true);
  System.out.println(method.invoke(a,new Object[]{}));
  Field field=a.getClass().getDeclaredField("message");
  field.setAccessible(true);
  System.out.println(field.get(a));
 }
}

Saturday, March 14, 2015

Hackers Motto

Nothing is secure.
Giving enough time and resources anything can be broken in to.