install apache benchmarking tool - ‘ab’

On WINDOWS machine :

Download httpd-****-x86 from http://httpd.apache.org/download.cgi

After going through the installation process –> Go to the directory where its installed

similar to C:\httpd-2.4.12-x86\Apache24\bin in my case, add this to system ENV Variable

 

On UNIX machine :

did not work –>> sudo yum install httpd-tools

Below long procedure worked, and it also needed to switch to root user and running it, running command with sudo did not work

You will need to install apr-utils and yum-utils first.

yum -y install apr-util
yum -y install yum-utils

 

extract Apache Benchmark from httpd-tools. And here is how.

mkdir ~/httpd-tools

cd ~/httpd-tools

yumdownloader httpd-tools

 

Now extract ab (Apache Benchmark) and move it to  /usr/bin  folder

rpm2cpio httpd-tools-2.2.24-1.29.amzn1.x86_64.rpm | cpio -idmv

mv usr/bin/ab /usr/bin/ab

cd ~

rm -rf ~/httpd-tools

 

 

sample command to test with -

ab -ki -n 500000 -c 200 http://rusticode.com/2013/04/07/lannn-installing-apache-benchmark-on-centos-ec2-linux-ami-with-nginx/

-n    specifies the number of requests,

-c    number of concurrent connections,

-k    stands for HTTP Keep-Alive,  

-t    maximum time of awaiting for response from connection

Setup up ssh to login without entering password

Considering situation where we need to connect from Server A to Server B

  • On Server A, run the below command to generate the public key

    ssh-keygen -t rsa

    Note: If you don’t have ssh-keygen command recognized in your system, install Git - which will provide required file for running ssh-keygen command.

    After installing Git, add this/similar path to your system environment variable C:\Program Files (x86)\Git\bin\ssh-keygen.exe

    This command should generate id_rsa.pub file in your <homedir>/.ssh/ directory

  • On Server B

    create a folder in the <homedir> with name .ssh

    Copy the id_rsa.pub file from Server A, into this .ssh directory.

    Append the contents of id_rsa.pub file to authorized_keys file inside the .ssh directory on Server B.  If one authorized_keys file does not exist – create it.

That’s it! now we should be able to login without having to enter password every single time.

Loading jndi.properties file from specific path

         Context context = null;
         try {
                File configFile = new File("<provide absolute path to your my.jndi.properties file>");
                Properties prop = new Properties();
                FileInputStream istream = new FileInputStream(configFile);
                prop.load(istream);
                context = new InitialContext(prop);
            } catch (NamingException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

Java Single Jar file with multiple main method classes

/**
* Sample launcher
*/
public class Launcher {

    public static void main(String[] args) throws Exception {
        if (args != null && args.length > 0) {
            String option = args[0];
            String[] args2 = new String[0];

            if (args.length > 1) {
                args2 = new String[args.length - 1];
                System.arraycopy(args, 1, args2, 0, args2.length);
            }

            if (option.equals("JbossJavaTCPSender"))
                new JbossJavaTCPSender().exec(args2);
            else if (option.equals("JbossJavaTCPReceiver"))
                new JbossJavaTCPReceiver().exec(args2);
            else
                System.out.println("Connot find such class to execute having name ["
                        + option+"]");
        } else
            {
            System.out.println("Usage : Provide ClassName as an argument to execute.");
            System.out.println("\t[java -jar JbossJavaTCPExample.jar JbossJavaTCPSender]");
            System.out.println("\t[java -jar JbossJavaTCPExample.jar JbossJavaTCPReceiver]");
            }
    }
}

Pushing local repository to Github

Install Git

Download and run the latest version of GIT from http://msysgit.github.io/ or http://git-scm.com/

Then go to http://github.com/ and create an account and repository.

During the installation you can accept all of the defaults, do not change 'Use Git and optional Unix tools from the Windows Command Prompt' option for Git and SSH operations, shown below:

 


After the installation is completed, to verify that Git is correctly configured run:



git --version



If the version of Git is displayed, means Git was installed successfully and has been add to path env variable.



On your machine, first you will need to navigate to the project folder using git bash. When you get there you do:



git init


which initiates a new git repository in that directory.



When you've done that, you need to register that new repo with a remote (where you'll upload -- push -- your files to), which in this case will be github. You'll get the correct URL from your repo on GitHub.



$ git remote add origin https://github.com/[username]/[reponame].git


You need to add you existing files to your local commit:



git add .   # this adds all the files


git pull https://github.com/[username]/[reponame].git


Then you need to make an initial commit, so you do:



git commit -a -m "Initial commit" # this stages your files locally for commit. 
# they haven't actually been pushed yet


Now you've created a commit in your local repo, but not in the remote one. To put it on the remote, you do the second line you posted:



git push -u origin --all

java.lang.ClassNotFoundException: javax.jms.JMSException

Solution:

Specify all the jar files used explicitly, specifying a folder having the jar files would not work.

windows task scheduler

Control Panel\All Control Panel Items\Administrative Tools –> Task scheduler –> create basic task