How to find out which jar file a class is loaded from

There are ways to programmatically find out where the java classloader loads a certain class from. But what if you don't have access to the source code and are on a production environment.
In these cases JVM provides you with a nice option :
-verbose:class

So if you are working with a an app server like WebLogic or Tomcat, just modify the appropriate script that sets JVM arguments and you should be able to see output like this in your server log :

 [Loaded java.io.Serializable from C:\Program Files\Java\jdk1.7.0_04\jre\lib\rt.jar]
[Loaded java.lang.Comparable from C:\Program Files\Java\jdk1.7.0_04\jre\lib\rt.jar]
[Loaded java.lang.CharSequence from C:\Program Files\Java\jdk1.7.0_04\jre\lib\rt.jar]
..............................................................................
..............................................................................
..............................................................................

Best way to transfer large file or resume dropped ftp/scp file transfers


When transferring large files your first choice should be rsync, since it gives you the ability to resume unfinished/dropped transfers. However, if you started a large file transfer with ftp/sftp or scp and the connection was lost during the transfer, you don't need to start over again. Simply run rsync the following way and it will resume your transfer :

rsync --partial --progress --rsh=ssh <USER>@<HOST>:<REMOTE_FILE_PATH> <LOCAL_FILE_PATH> 

This command is what should be used for large file transfers.

How to create an executable jar with 3rd party dependencies included in the jar

If you have written a small java utility that has dependencies on other 3rd party jar and you would like other people to use it without building your jar, you will need to include those jars in your jar. To do this you need to use the maven-assembly-plugin .

So inside <build> ... <plugins>  of your pom.xml put

<plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <configuration>
        <archive>
          <manifest>
            <mainClass>your.fully.qualified.MainClass</mainClass>
          </manifest>
        </archive>
        <descriptorRefs>
          <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
      </configuration>
</plugin>

Then run maven using :  mvn clean compile assembly:single

How to install VNC on Redhat and avoid getting "font catalog is not properly configured" error

 yum install -y  tigervnc-server tigervnc-server-module libXfont pixman xterm xorg-x11-twm

Setting YUM proxy settings in Redhat

If you are behind a proxy YUM won't be able to connect to its repositories. To fix this you will need to add your proxy setting to /etc/yum.conf

If you are using an anonymous proxy, only the following line needs to get added to yum.conf

proxy=http://<poxy-server>:<proxy-port>/

In case your proxy server requires authentication also add the following lines in addtion to the above

proxy_username=<proxy-user>
proxy_password=<proxy-password>

Determining schemas inside an Oracle data pump/dump file

Have you ever wondered how you can findout the schema or tablespace names contained within an Oracle Datapump dump or export?

Well, there is a way and it's an easy one:

First make sure ORACLE_SID and ORACLE_HOME is corectly set and Oracle binaries are in your PATH. Then using a user with appropriate privillages execute :

impdp \'/ as sysdba\' dumpfile=<YOUR_DMP_FILENAME>.dmp sqlfile=<OUTPUT_FILENAME>.txt

After this is done, simply open the text file for viewing and look for statements like :
CREATE USER ......