Skip to main content

Posts

How to Setup SFTP Server Using GCP VM With a Mounted GCP Bucket

SFTP is the secured method of implementing FTP where you can use a server or storage location as FTP location which you can transfer files from your local computer to remote server. In this article we discuss how to create a SFTP server using GCP (Google Cloud Platform).  Even though the best way is to use a GCP bucket which is low cost for large file storage in GCP theres no direct way to implement a SFTP connection directly to the bucket. Therefore we need to have a VM (Virtual Machine) in GCP in order to act as a server for file transfers.  Generate SSH keys Generate the SSH keys using following command. This generates a public key and a private key which we going to use later. ssh-keygen -b 4096 -t rsa Create VM in GCP First of all you need to create a GCP account here  which they provide $300 credit for new users which is enough for you to get start for free. To create a VM you need to access Compute Engine and VM instances.  Create Bucket Login to Gcloud Setup OS Login SSH to use
Recent posts

Java Version and New Features 8 - 13

Introduction Introduction Java is widely used staticly typed programming language which is founded over 25 years back. It's almost everywhere from home appliances, mobile devices to industry scale systems. Java is evolving over the time and from Java 8 onwards there were major changes introduced to the language. Below are the list of all the changes on each version. Imperative vs Declarative Programming Imperative approach is defining step by step on HOW we are going to achieve the end result. Declarative approach is describing WHAT we want as the output. Simple example would be a classical for loop in Java which we can call as imperative programming and a select query in sql as declarative programming.

Java 5

Java 5 is known as the “ Tiger ” release since it released many of the key features many of the developers used today. Many interview questions are based on this version. Following are the key features introduced in Java 5 Generics Annotations Autoboxing / Unboxing Typesafe Enums Varargs Foreach Loop Static Imports Scanner Class Assertions StringBuilder

Generics

What are Generics? Java Generics are a language feature that allows for definition and use of generic types and methods. Didn’t get it? Then Why Generics? “In layman,s term, generics force type safety in java language and therefore add stability to your code by making more of your bugs detectable at compile time.” Thats the definition. Still not clear? Ok Let’s see How it works! Let’s assume you create an ArrayList that only works with Integers and you execute it with following values. As of following example it will give an error at runtime which is late to identify and error in a highly scaled dynamic application(I mean later when you are an expert ;)) List list = new ArrayList(); list.add(1000); //works fine list.add("Gothama"); //run time error; Let’s see how Generics solves the problem at compile time with following example. List<Integer> list = new ArrayList<Integer>(); list.add(1000); //works fine list.add("Gothama"); //com

Annotations

What are annotations? Annotations are meta data in Java. What is meta data? A metadata is data about data. Metadata adds some additional flags on your actual data, and in runtime either you or JVM who understand these flags, can utilize this metadata information to make appropriate decisions based on context. How it looks like? Basic annotation is look like following. @ MyAnnotation It starts with @ sign followed by the Annotation name. Annotations are defined as following. @interface MyAnnotation { } I didn’t get it… Ok, Annotations do basically three things in Java. It provides…. Embed instructions to Java Compiler Embed instructions to Source Code Processing Tools such as IDEs Embed metadata which can be read at runtime by your Java Application or Third Party Tools Lets look at some simple example Below example shows how @Override annotation checks that the annotated method is overridden method. public class DemoClass { //some code @Override public Str

Autoboxing / Unboxing

What it is? Even though the name includes boxing, this is all about wrapping and unwrapping primitive types with its corresponding wrapper class. No Idea… Ok, Following example will explain all. // Java program to illustrate the concept // of Autoboxing and Unboxing import java.io.*; class Independor { public static void main (String[] args) { // creating an Integer Object (wrapper class of int) // with value 10. Integer i = new Integer(10); // unboxing the Object int i1 = i; System.out.println("Value of i: " + i); System.out.println("Value of i1: " + i1); //Autoboxing of char Character gfg = 'a'; // Auto-unboxing of Character (wrapper class of char) char ch = gfg; System.out.println("Value of ch: " + ch); System.out.println("Value of gfg: " + gfg); } } Following are the primitiv

Java Versions and New Features

What are  new java features in java  version 7 or 8? These are pretty much frequently asked questions in java interviews. In this page, I listing down all  JDK changes from JDK 1.x to Java SE 12 , sequentially. Though I have tried to cover as much as information I can gather, though if you know something which I missed below, please let me know and I will add that information. Java 12 Features Java 12  (released on March 19, 2019) is latest version available for JDK. Let’s see the new features and improvements, it brings for developers and architects. Collectors.teeing() in Stream API String API Changes Files.mismatch(Path, Path) Compact Number Formatting Support for Unicode 11 Switch Expressions (Preview) Java 11 Features Java 11  (released on September 2018) includes many important and useful updates. Let’s see the new features and improvements, it brings for developers and architects. HTTP Client API Launch Single-File Programs Without Compilation String A