Thursday, November 20, 2014

Unsupported major.minor in Java


Exception in thread "main" java.lang.UnsupportedClassVersionError: Concordance : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: Concordance.  Program will exit.

If your  java program shows above error, then you compiled the file in higher version of java from the version you are executing this jar / war / class.

Ex : Compiled in java 7 and running the program in java 6 (lower version).

How to resolve : Re-compile the program in java 6 to avoid the issues and execute the same. Check your JAVA_HOME added in your PATH  once.

Which is Allowed : You can compile in java 6 and run in java 7 is allowed. Program compiled in lower version  class file can run in higher version. Other-way around is not allowed.

Monday, July 14, 2014

nginx Web Server

Install nginx in centOS 6

Create a file in yum repository for nginx with its repo.
vi /etc/yum.repos.d/nginx.repo

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/6/$basearch/
gpgcheck=0
enabled=1

Once you saved the file
yum install nginx
service nginx start
service nginx status
By default nginx will be started and available in port :80.

  On the same server, protect the Java server from external access 

If you are running Nginx on the same server of the Java, the best practice is to deny access to port 8080 so only Nginx can access it. On Linux do:

/sbin/iptables -A INPUT -p tcp -i eth0 --dport 8080 -j REJECT --reject-with tcp-reset
 
Reference : http://wiki.nginx.org/JavaServers
// Below script tag for SyntaxHighLighter