Git – Permission denied (publickey) Error while cloning the repo on Windows.

The above error comes when either you haven’t made any SSH keys on your local machine or those keys are expired. So to solve this, Please follow the below steps –

  1. Open git bash.
  2. Type cd ~/.ssh. This will take you to the root directory for Git (Likely C:\Users\[YOUR-USER-NAME]\.ssh\ on Windows)
  3. Within the .ssh folder, there should be these two files: id_rsa and id_rsa.pub.
  4. Copy the content of id_rsa.pub with no extra spaces or lines and paste it into GitHub under the Account Settings > SSH Keys. You can name as per your convenience.
  5. Now git clone or git pull should work.

In case the above files are not created, you can use the below command to do so –

cd ~/.ssh && ssh-keygen

Now follow all the above mentioned steps. Hope it will solve your problem.

How to redirect an URL using REST Java

There are multiple ways to perform redirection. Actually 3x family of HTTP plays a vital role while performing URL redirection in the below ways –

1. 301 Moved Permanently

String url = https://google.com/api/oauth/code?response_type=code&client_id=YOUR_CLIENT_ID&redirect_uri=https://localhost:8443/myapp/test”;

URI uri=new URI(url);

return Response.status(Status.MOVED_PERMANENTLY).location(uri).build();

Now it’ll redirect you to your localhost endpoint defined in the parameter redirect_uri permanently.

2. 307 Temporary Redirect

return Response.temporaryRedirect(uri).build();

 

How to enable SSL/HTTPS in Java Micro-Service/Spring-Boot application

  1. Generate SSL certificate –

keytool -genkey -alias <alias> -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore keystore.p12 -validity 3650

  1. Add the below lines in your application.properties file –

server.port: 8443

server.ssl.key-store: classpath : keystore.p12

server.ssl.key-store-password: <keystore password>

server.ssl.keyStoreType: PKCS12

server.ssl.keyAlias: <alias>

3. Restart your java application. Now you’ll be able to access your application over HTTPS on https://localhost:8443 instead of http://localhost:8080.

Windows VMware Issue: VMware Workstation and Hyper-V are not compatible. Remove the Hyper-V role from the system before running VMware Workstation.

Recently I have gotten into this issue after updating my windows. Before updating my windows machine, I was able to boot up my virtual machine. After that it got failed saying “VMware Workstation and Hyper-V are not compatible. Remove the Hyper-V role from the system before running VMware Workstation.”. Below is the required steps to solve this issue –

1.) Go to “Programs and Features” icon on your windows machine.

2.) Click on “Turn Windows features on or off”.

3.) When the new window opens, uncheck the checkbox labelled as “Hyper-V”.

4.) Now it will ask you to reboot your system.

5.) After the PC restarts, try to launch VMWare again. I worked for me. Hope it helps you as well. 🙂 

Stuck in verifying while installing pkg file on MAC

  1. Go to finder. Click on Go and then Go to Folder and type /System/Library/CoreServices/Installer.app. Then invoke the installer.app
  2. Now you just need to go to the location where .pkg file exists and that was stuck in verifying.
  3. Select the file to open and now you will be able to run the installer easily.

It saved my day. Hope it helps for you as well. 🙂

Kill process/port on MAC machine in case of java.net.BindException: Address already in use

  • First try netstat –
    netstat -vanp tcp | grep <PORT Number(8061)>

    Result

    tcp46      0      0  *.8061                 *.*                    LISTEN      131072 131072  71666      0

  • The Find the PID for the locking port –
    lsof -i :<PORT Number(8061)>
    

    Result

    COMMAND   PID     USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME

    java    71666 tangupta   90u  IPv6 0x9f73e601cf2fbd79      0t0  TCP *:8061 (LISTEN)

  • Kill:
    kill -9 <PID(71666)>

Result – Process running on the above port would be killed. Now you can resume your           work on the above port which was blocked.