Skip to main content

Posts

How to read a file inside a jar using the command line?

It's simple. Assume the following. Your jar file : myJarFile.jar First you can list the contents of the jar to find the file you want using the following command.                              jar tvf myJarFile.jar Then from the list, pick the file you want and type in the following command to see the content of that file. Assuming the file within the jar is myFolder/myFile.txt ,                unzip -p myJarFile.jar myFolder/myFile.txt Then the contents of the file could be seen in the command line. Cheers.

Integrating the JaCoCo code coverage plugin into a Java Maven project for unit testing with testng

I’ll show how to do this for both offline instrumentation and for using the JaCoCo runtime agent. It is very easy because you don’t need to change the usual way of writing your tests. Its only a matter of changing the pom.xml file in your maven project. 1. JaCoCo code coverage with JaCoCo runtime agent Since we use testng for unit test writing, we put the following dependency under dependencies. < dependencies > < dependency > < groupId > org.testng </ groupId > < artifactId > testng </ artifactId > < version > ${testng.version} </ version > < scope > test </ scope > </ dependency > </ dependencies > Then under build, we first need to have the JaCoCo plugin put under the plugins section of your project pom.xml. (Note - this is the parent pom we are referring to) This plugin configuration...

Installing Oracle Database 11g Release 2 hangs at Desktop Class (step 4) in Windows 7

The following steps should be followed to solve this problem. 1. Run cmd as Administrator. 2. Navigate to the directory where the your setup.exe resides for oracle 11g using the cmd. 3. Type the following command and press enter. Remember to give the path to where your java jdk is installed in your system here. Most importantly, I have used PROGRA~1 as a replacement for the string "Program Files". The reason for the installer to hang at step 4 is it cannot find the correct path to the JDK when the path contains spaces. Use PROGRA~2 as a replacement for the string "Program Files (x86)". This depends on where your JDK is installed. setup.exe -jreLoc C:\PROGRA~1\Java\jdk1.8.0_40 Cheers :)

How to undo an accidental git merge that has not been pushed to GitHub yet?

There are several ways to do this. You can try out one of the following commands . 1. git reset --hard <commit_sha> Check  git log  to find the commit_sha for the command above. 2. git reset --hard HEAD~5 Five here is the number of commits that you need to get back. 3. git reset --hard ORIG_HEAD   ORIG_HEAD  will point to a commit directly before merge has occurred. You don't need to find for the commit_sha. Cheers. :)

How to delete multiple files from Git at once in Git Bash or Ubuntu?

You can easily delete a single file from GitHub through the browser, but how can we delete a bunch of files altogether using Git so that you do not have to delete them one by one? The most easiest step is to type the following command to track all the files that are deleted and remove them. git ls-files --deleted -z | xargs -0 git rm   After executing the above command, when you type the following command, you will see that all the deleted files have been added to commit. They are in green. git status Now you have to make a commit and push to your origin. Note: To remove a single file or a couple of files from the command line or git bash, you type the following. git rm file1 file2 file3 Cheers. :)

How to connect my database instance with elastic beanstalk instance in AWS?

If you have deployed your web application in Elastic Beanstalk in AWS and now you need to connect a database to this instance, and your database is actually residing in a different instance, how can you actually connect them? It's easy with Elastic Beanstalk. I will explain an example scenario that I used for connecting my elastic beanstalk web application with another instance containing my MongoDB database. By looking at this, you can customize as per your need. Don't worry. This is easy. :) The only things you need here are the details about the 1. Database name that you need to connect to. Ex:- "myDB" 2. Port at which the database instance is listening. EX:- In the case of MongoDB, the listening port is 27017 3. Host name of your database instance. EX:- Like localhost, in this case, it will be the Public DNS of your database instance 4. The password of your database if exists. First these details need to be set as environment variables in Elastic Be...