Monday, June 18, 2012

how to find byte code class file JDK compiled java version

you can find out the byte code class version.

On Linux, Mac OS X or Windows with Cygwin installed, the file(1) command knows the class version. Extract a class from a jar and use file to identify it:

$ jar xf log4j-1.2.15.jar
$ file ./org/apache/log4j/Appender.class
./org/apache/log4j/Appender.class: compiled Java class data, version 45.3

A different class version, for example:

root@mypc:/merchant-sample/classes/com/paypal/core$ file SSLUtil.class 
SSLUtil.class: compiled Java class data, version 50.0 (Java 1.6)

The class version major number corresponds to the following Java JDK versions:

46 = Java 1.2
47 = Java 1.3
48 = Java 1.4
49 = Java 5
50 = Java 6
51 = Java 7

Alternatively, you can make a simple test class that can identify class version.
public class Test {
    public static void main(String[] args) throws IOException {
        checkClassVersion("Class path you want to know");
    private static void checkClassVersion(String filename)
        throws IOException
        DataInputStream in = new DataInputStream
         (new FileInputStream(filename));
        int magic = in.readInt();
        if(magic != 0xcafebabe) {
          System.out.println(filename + " is not a valid class!");;
        int minor = in.readUnsignedShort();
        int major = in.readUnsignedShort();
        System.out.println(filename + ": " + major + " . " + minor);

Thursday, June 14, 2012

Configure Proxy server bypass or pass

When you work in enterprise environment, you will most likely need to use proxy server either you like or not.

I have suffered for long time because proxy setting and I had to have customized proxy bypass script due to development.

I would like to share my snippet. I hope it helps.

Ubuntu apt-get Proxy configuration. For more detail

Maven test proxy setting

Eclipse proxy set up for JRE/JDK

Eclipse Network Proxy configuration for installing new sofware or update plugins

Eclipse Tomcat proxy set up
add below text
 -Dhttp.proxyHost="" -Dhttp.proxyPort="8080" -Dhttps.proxyHost="" -Dhttps.proxyPort="8080"

Internet Explorer Proxy configuration

Eclipse Java application Proxy configuration

Ubuntu Proxy for chrome browser

Firefox Proxy configuration

Proxy Automate Script(PAC) sample

Configuration Example path

For IE on Windows

For FF on Windows

For FF on Ubuntu
var PROXY1 = "PROXY";
var PROXYY2 = "PROXY";

var regexpr_facebook = /^[.a-zA-Z0-9-]*;
var myip = myIpAddress();

//url =
//host =
function FindProxyForURL(url, host){

 //For Home AP access ( If Source IP starts with 192.168.x.x) bypass Proxy
 if (isInNet(myip, "", "")) {
  return DIRECT;
 //your local computer bypass Proxy
 }else if (isInNet(host, "", "") || host=="localhost") {
  return DIRECT;
 //C class subnet mask by pass Proxy(it means all IPs starts with 111.111.111 will bypass
 }else if (isInNet(host, "", "") ) {
  return DIRECT;
 //When you need to access from host file definition IPs
 }else if (host=="devsite"|| host=="mytest") {
  return DIRECT;
 //if you need proxy for specific ip ranges ( Domain will be resolved by DNS ang get IP)
 }else if (isInNet(myip, "", "") ) {
  return PROXY1;
 //if you need proxy for specific domain address
 }else if (regexpr_facebook.test(host)){
  return PROXYY2;
  return PROXY1;