Posts

Showing posts from 2019

Install and Switch multiple versions of Java JDK on Linux or MacOS

While working on enterprise level, we often have java projects running on older versions of java for legacy reasons. Hence it is not very uncommon for a developer to have multiple versions of JDK installed in their machines and easy way to switch different versions of JDK on demand for running the build. This blog explains the steps needed to setup and configure multiple JDK versions on Mac OS. Get the architecture of the Machine from Terminal using: uname -m Create a directory for installation: mkdir -p $HOME/tools/java Download java binaries: Download java 25 and 21 binary for Linux / Mac OS operating system with the correct architecture type to directory $HOME/tools/java Download URL https://adoptium.net/en-GB/temurin/releases?mode=filter&os=any&arch=any Extract and rename java binaries: find $HOME/tools/java -type f -name OpenJDK25*.tar.gz | xargs -I {} mv {} $HOME/tools/java/OpenJDK25.tar.gz find $HOME/tools/java -type f -name OpenJDK21*.tar.gz | xargs -I {} mv {} $HOM...

Docker Community Edition download without login

Docker recently changed their download mechanism, which prevented users from downloading the Community Edition without log in. In my opinion, the registration and login should be an optional step instead of a mandatory field. Hence I am listing the download link for Mac OS and Windows OS that allows downloading the Docker Community Edition without having to register an account with login. Mac OS: https://download.docker.com/mac/stable/Docker.dmg Windows OS: https://download.docker.com/win/stable/Docker%20for%20Windows%20Installer.exe

Kotlin / Ktor / Jdbi Json / Api / Free Marker / VueJs

Image
About this blog A brief reason for writing this blog. I am a server side http api / web developer predominantly using JVM based languages. Recently I started using Kotlin programming language (developed by JetBrains) with Spring Boot Framework on AWS cloud to build an enterprise solution (including both API and small web portal for internal Admins) to serve data for the mobile apps. I loved Kotlin as a programming language for Server Side development. So I was curious to explore Ktor Framework (developed and sponsored by JetBrains) for Server Side Web Development (API & Webpages). Hence I created a sample repository in Git Hub to play with Ktor Framework to experiment with various enterprise grade features offered by Ktor Framework. Please read this blog in conjuction with my Kotlin repository available at https://github.com/harishkannarao/kotlin High Level Components Diagram API The API development was very very simple with Jackson / Google GSON integration. The...

IntelliJ IDEA TestNG include and exclude groups

Image
This posts explains test filtering of TestNG tests in IntelliJ IDEA by including and excluding groups. Please follow the steps as given below to create configuration to run multiple tests in your project / module: Click Run menu Select Edit Configurations.. Click + icon ( Add New Configuration ) Select TestNG Set Name as Groups Change Test Kind: to Pattern Set Pattern: to com.harishkannarao.* (your project's root package) Set Test runner params: as  -groups "API_INTEGRATION_TEST,WEB_INTEGRATION_TEST" -excludegroups "AUTH_API_INTEGRATION_TEST" Click OK Running the configuration: Click Run menu Select Run... Select Groups

Essential SSH commands

The following ssh commands are used by me in everyday development activity. So it prompted me to write a blog post about the essential SSH commands during java development. SSH to a remote server using username and password ssh username@remote-server-host-or-ip SSH to a remote server with a specific port (other than 22) ssh username@remote-server-host-or-ip -p 26 SSH to a remote server using private key (or identity file) ssh -i /path/to/private-key.pem username@remote-server-host-or-ip SSH without host checking ssh -o "StrictHostKeyChecking no" username@remote-server-host-or-ip This avoids the manual confirmation check prompted as given below The authenticity of host '111.222.333.444 (111.222.333.444)' can't be established. RSA key fingerprint is f3:cf:58:ae:71:0b:c8:04:6f:34:a3:b2:e4:1e:0c:8b. Are you sure you want to continue connecting (yes/no)? SSH to a remote server with agent forwarding The following command forwards your SSH auth schem...

Remote JVM monitoring using VisualVM

Image
Most of the modern JVM application frameworks like Spring Boot, Dropwizard and Ktor uses executable jars to bootstrap application with servers embedded inside the jar. The following steps will allow you to monitor the remote JVM running in cloud (or in house data center) using SSH port forwarding and Java JMX. In order to monitor the remote JVM, the java process needs to be started with extra system properties to enable JMX features and you should be able to SSH into the machine where the JVM is running. Start the Java application (or Java Process) with JMX enabled as given below: java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=10006 -Dcom.sun.management.jmxremote.rmi.port=10006 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.local.only=false -Djava.rmi.server.hostname=localhost -jar spring-boot-application.jar Create a SSH tunnel with port forwarding for JMX port ssh -L 10006...

Smart search / replace with regular expression and back reference

As a developer, I had to search and replace in my source code within single file or whole project. Occasionally the search and replace could involve regular expression and back reference to groups found in regular expression. For example: I need to replace equalTo("value 1234") to "value 1234" equalTo("value 5678") to "value 5678" These smart search and replace needs regular expression and back reference to the group. The following is an example to perform it through IDE like IntelliJ IDEA or Microsoft Visual Studio Code (VS Code) Search Reg Ex: equalTo\("(.*)"\) Replace Reg Ex: "$1" The same can be performed using sed as shown below For single file: sed -i '' -E 's/equalTo\("(.*)"\)/"\1"/g' some_file.txt For multiple files using find and xargs: find . -name "some_file*.txt" -print0 | xargs -0 -I {} sed -i '' -E 's/equalTo\("(.*)"\)/...