Tuesday, March 22, 2016

Java Interview Preparation Links


Different Java Versions and Important Features

https://ondro.inginea.eu/index.php/new-features-in-java-versions-since-java-8/


Java Links

Exception handling

Interview Questions

Java Strings

Collections


Design Pattern


OOPS Concepts

Generics In Java

Threads
Executor,Executor Service


Frameworks

Friday, June 13, 2014

Git Basic Commands


Set user.name and user.email in config file

$ git config --global user.name "John Doe" $ git config --global user.email johndoe@example.com

See the config setting in your git

$ git config --list user.name=Scott Chacon user.email=schacon@gmail.com color.status=auto color.branch=auto color.interactive=auto color.diff=auto ...

Getting Help

$ git help $ git --help $ man git-

Initializing a repository

$ git init

Add a file to the repository

$ git add *.c 
OR $ git add README

Clone a repository

$ git clone git://github.com/schacon/grit.git
OR
$ git clone https://github.com/schacon/grit.git


Clone a repository in a particular folder

$ git clone https://github.com/schacon/grit.git mygrit

Check status of the files

$ git status

Checkout a branch

$ git checkout

Checkout and create a branch

$ git checkout -b

Commit the changes

$ git commit -m "comment"

Push the changes to the branch

$ git push origin

See the logs

$ git log

git

git


References:








Tuesday, June 10, 2014

Find if the port is already in use in Windows

In the command prompt use the following command to find if a port is already in use:

C:\Users\username>netstat -an |find /i "2990"

Tuesday, April 8, 2014

Convert Input Stream to ByteArray

Converting the Input Stream to Byte Array is very simple. You can org.apache.commons.io.IOUtils to get the job done quickly.

The IOUtils contains a method toByteArray which takes in a InputStream and converts the input stream into a byte Array.


byte[] byteArray = IOUtils.toByteArray(in);

How to change Byte array byte[] to InputStream



The byte array can be converted into the input stream using the java.io.ByteArrayInputStream class. The ByteArrayInputStream class extends the InputStream class.

In the constructor of the ByteArrayInputStream just pass the byte array (byte[]) which you want to convert into InputStream.

InputStream stream = new ByteArrayInputStream(myBytes);

Friday, March 21, 2014

Remote X11 Over SSH

Remote X11 Over SSH

On the remote machine (Linux):
1) Ensure that X11Forwarding is enabled in /etc/ssh/sshd_conf on the remote machine.

On the local machine (Windows):
2) Install Xming.
 3) Add the Linux machine's DNS name(s) and IP address to the C:\Program Files\xming\X0.hosts file. File should containthe IP of the server for which you want X11 forwarding:
   localhost
   192.168.1.25
4) Start Xming on your Windows machine (NOT XLaunch)
5) Install SSH Secure Shell(if it's not already installed) onto your Windows machine.
6) Open ssh client and fill in the “Host Name” box.
7) Ensure the port is correct (probably 22).
8) Under Settings > Tunneling > X11 check the “Tunnel X11 connections” box.
9) If you create a profile then ensure tunneling is enabled on the profile as well.
10) Start the connection.
11) Log into the remote machine as you would do in a normal SSH session.
12) Start the X application from the command line, a window should open on your local machine with the application.
13) Minimize the SSH session, do not close it. If you close it, your X connections will close.
(It's a regular SSH session with putty but with X11 forwarding enabled.)

*The steps are pretty much the same for putty as well. you just need to switch on X11 forwarding in putty.

1) Open putty and fill in the “Host Name” box.
2) Ensure that SSH is checked and that the port is correct (probably 22).
3) Under Category > Connection > SSH > X11 check the “Enable X11 forwarding” box.
4) Click the “Open” button to start the connection.
5) Log into the remote machine as you would do in a normal SSH session.
6) Start the X application from the command line, a window should open on your local machine with the application.
7) Minimize the SSH session, do not close it. If you close it, your X connections will close.
(It's a regular SSH session with putty but with X11 forwarding enabled.)

Wednesday, March 19, 2014

Java.Lang.NoClassDefFoundError : Org/Apache/Commons/Fileupload/FileUploadException





java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileUploadException
 java.lang.Class.getDeclaredConstructors0(Native Method)
 java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
 java.lang.Class.getConstructor0(Unknown Source)
 java.lang.Class.newInstance0(Unknown Source)
 java.lang.Class.newInstance(Unknown Source)
If you see the above error then you can solve the issue by simply adding the below dependency in your pom.xml

<dependency>
  <groupId>commons-fileupload</groupId>
  <artifactId&gtcommons-fileupload</artifactId>
  <version&gt1.3</version>
</dependency>