Skip to main content


Java Telnet example : testing remote service state

In most of the cases in daily job, you must have get into some situation where you needed to telnet to a machine. Although telnet is not a secure way to access remote machine, but still it can be useful if all we want to know if the particular service port on particular machine is running or not(for example you want to check say on local ip address 192.168.110 on port 3389 the RDP service is running or not and there may be other cases)

Below, we will be showing up sample code in java which you can use the automate the process. This can also be used anywhere like if you are writing a service to report health of the multiple services, just a case.; import; import; public class JavaTelnetExample { private static final String RDP_SERVER = ""; private static final int RDP_SERVER_PORT = 3389; private static final String HTTP_SERVER = ""; …
Recent posts

2 Steps to restrict Jenkins access by IP address or Host Name

Steps to fresh jenkins installtion on on Apache Tomcat Server :
If Jenkins is installed on Tomcat Server 

Add any of the below entry in the conf\context.xml file :<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow=""/><!--Allow from Ip Address--><Valve className="org.apache.catalina.valves.RemoteAddrValve" deny=""/><!--Deny from Ip Address--><Valve className="org.apache.catalina.valves.RemoteHostValve" allow=""/><!--Allow from a Domain--><Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|"/><!--Allow from multipl ip's--> Restart the Tomcat ServerNow, when you try to access Jenkins url, you should get 403 error
If Jenkins is installed on Apache Server 

Add all of the bel…

Installing Jenkins on Apache Tomcat Server

First of all if you have not installed the Apache Tomcat Server, We will be going to install it on Windows following the below steps :Download the Apache Server from Url :
Extract the Tomcat zip folderNavigate to to 'conf' directory, path may be somewhat like '..\apache-tomcat-9.0.0.M8\conf' from where you have extracted the zip.Open the Server.xml file and edit the PORT where you want the Tomcat to listen for the requests
Now start Command Prompt and go to '..\apache-tomcat-9.0.0.M8\bin' and call 'startup.bat'Now start a browser and navigate to url '<your_system_ip:port_specified_in_step4>'. Example : should see Tomcat Successfully installed page. Congratulation!

Now, we will be moving to next part of configuring Jenkins behind the Tomcat Server  : Download Jenkins.war file from downloaded, unzip and move the jenkins.war to directory '.\apache-tomcat-9.0.0.…

Connecting to MySql from java with Maven

In this example we will be creating a simple maven java project to connect to the local mysql instance, without actually installing any jdbc connector and setting it to classpath (maven will take care of this :))

1. Add MySQL connector maven dependency in the pom.xml

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="" xmlns:xsi="" xsi:schemaLocation=""> <modelVersion>4.0.0</modelVersion> <groupId>com.automatethebox</groupId> <artifactId>mysql-connect-maven</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <vers…

Disable Java JVM Default DNS Caching

You can disable the Java Virtual machine default DNS caching following any of the below methods
( By Default java 1.6 caches all the DNS queries ):

Method 1(Changes while staring up JVM)Add while starting up the JVM.
Method 2(Changes in java config file)Add/Edit the property networkaddress.cache.ttl=0 in %JRE%/lib/security/ file. Here JRE refers to Java Runtime Environment folder.
Method 3(Changes in your code)Set the property in you java code as"networkaddress.cache.ttl", "0" );

Solving Gradle DSL method not found : 'android()'

Getting "Gradle DSL method not found : 'android()" error, well then you are at right place to solve the things :)

Open the project top level 'build.gradle' fileRemove the below configuration  android() method  // Delete these lines from project top level 'build.gradle' file android {  compileSdkVersion 23  buildToolsVersion '22.0.1' }
Save the changes and re-compile 

Configure Jenkins email notifications

In this tutorial we will discuss about setting up the email notification in your Jenkins environment from the start :

Part I: Configure the email notifications from Jenkins Management section.
Part II : Configure the email notification for the individual Jenkins job  

Part I: Configure the email notifications from Jenkins Management section.
First you should be logged in to Jenkins interface as Administrators, so you should see 'Manage Jenkins' link on the left side options.Click on the 'Manage Jenkins', to navigate to 'Manage Jenkins' page. 'Configure System' option should be availableClick on the 'Configure System' link, scroll down on 'Configure System' page, you should see the 'Email notifications' section.Set the following settings in the 'Email notification' section [We are taking yahoo domain for example]SMTP Server : 'Use SMTP Authentication'Username : <email address to send emails&…