Sunday, March 27, 2022

How to Install Maven Manually on macOS

 1) Download the Maven


2) Extract tar: 
% tar -xvzf apache-maven-3.6.3-bin.tar.gz -C ~

3) Now, move the maven folder to this path /Users/{username}/

4) Need to create file is at this path /Users/{username}/

% cd && touch .zshenv && open .zshenv


Note :

  • On macOS 10.5 Catalina or later, the default shell is zsh (.zshenv).
  • For macOS 10.14 Mojave and before, the default Terminal shell is bash (.bash_profile).


5) Adde below lines of code in appropriate files:


export M2_HOME="/Users/{username}/apache-maven-3.8.5"

PATH="${M2_HOME}/bin:${PATH}"

export PATH


6) Source the ~/.zshenv to reflect the changes:


% source ~/.zshenv


7) Verify to check using mvn:


 % mvn -version                       

Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)

Maven home: /Users/{username}/apache-maven-3.8.5

Java version: 11.0.13, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-11.0.13.jdk/Contents/Home

Default locale: en_IN, platform encoding: UTF-8

OS name: "mac os x", version: "11.3", arch: "x86_64", family: "mac"

meena@MEENAs-MacBook-Pro ~ % 

Thursday, March 21, 2019

Spring Boot , Hello World Example

Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run".
We take an opinionated view of the Spring platform and third-party libraries so you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration.
Features
  • Create stand-alone Spring applications
  • Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)
  • Provide opinionated 'starter' dependencies to simplify your build configuration
  • Automatically configure Spring and 3rd party libraries whenever possible
  • Provide production-ready features such as metrics, health checks and externalized configuration
  • Absolutely no code generation and no requirement for XML configuration
Technologies stack:
  • Spring Boot 2.1.3.RELEASE
  • Maven
  • JDK 1.8
Create Project:

To Create Project with spirng boot use https://start.spring.io/ which allow you to dowload .zip files. After download extract and import with IDE.



Project Structure:



Project Dependencies:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.commons</groupId>
<artifactId>SpringHelloWorld</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SpringHelloWorld</name>
<description>Demo project for Spring Boot</description>

<properties>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>

<!-- Need this to compile JSP -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>

Need to Add high lighted Dependency manually to run jsp 

Run Application: 

Now Run Main Class (where public static void main method define) from base package, In our case we have "SpringHelloWorldApplication", It will run tomcat with port 8080





It is better to conquer yourself than to win a thousand battles. Then the victory is yours. It cannot be taken from you, not by angels or by demons, heaven or hell. 
                                                                                                                          -Buddha


Friday, March 15, 2019

[Spring Interview Question] - Difference between BeanFactory and ApplicationContext in Spring?



BeanFactory ApplicationContext
Does not support the Annotation based dependency Injection. Support Annotation based dependency Injection.-@Autowired, @PreDestroy
Does not support. Can publish events to beans that are registered as listeners.
Does not support way to access Message Bundle(internationalization (I18N). Support internationalization (I18N) messages.
Does not support. Support many enterprise services such JNDI access, EJB integration, remoting.
By default its support Lazy loading. its By default support Aggresive loading.

GAE + spring + jersey restful + Hibernate

Google App Engine is a Platform as a Service (PaaS) product that provides Web app developers and enterprises with access to Google's scalable hosting and tier 1 Internet service.

I attachd source code for GAE + spring + jersey restful + Hibernate

https://github.com/me30/GAE-Restful-Jersey-Spring-Hibernate.git

Monday, December 5, 2016

Java Alternative Version For Ubantu

Choose Java Alternative Version :

When we have got multiple versions of Java installed, we can choose which one you want to use by running the update-alternatives command.
Running below command shows a list of installed Java JDKs and JREs allowing one to be selected as the default that is used when java needs to be executed.
$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
* 2 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual mode

Press enter to keep the current choice[*], or type selection number: 2
To choose a default javac compiler, run the following command.
$ sudo update-alternatives --config javac
If we prefer to use a gui instead of the command line, we can execute galternatives instead and define the default versions of software with the following dialog.
$ sudo galternatives

Saturday, December 3, 2016

Eclipse IDE - If server option is disable due to some issue

If server option is disable due to some issue when we configure tomcat then..
  1. Close Eclipse
  2. In {workspace-directory}/.metadata/.plugins/org.eclipse.core.runtime/.settingsdelete the following two files:
    • org.eclipse.wst.server.core.prefs
    • org.eclipse.jst.server.tomcat.core.prefs
  3. Restart Eclipse

Friday, November 11, 2016

Rotate Tomcat catalina.out (If catalina.out becomes bulky in size, tomcat crashes and fails to start without any error message)

Rotate Tomcat catalina.out

If catalina.out becomes bulky in size, tomcat crashes and fails to start without any error message. 

To avoid this scenario you should rotate catalina.out frequently. 

Step - 1)
create file [any directory] with name "tomcatrotate"

Step - 2)
add content

/opt/apache-tomcat-7.0.67/logs/catalina.out  {
compress
copytruncate
daily
dateext
dateformat %Y-%m-%d
extension .out
missingok
rotate 14
size 100k
su root root
}

Step – 3)
after move to - /etc/logrotate.d/
sudo cp -i /home/minesh/Downloads/tomcatrotate /etc/logrotate.d/

Step - 4)
change the permission 777 to 644
sudo chmod -R 644 lportal

Step – 5)
after this test with below command it will do empty catalina.out and create its catalina2016-11-11.out.gz.

sudo /usr/sbin/logrotate -vf -s /var/log/logrotate-status /etc/logrotate.d/tomcatrotate

special thanks : https://masterinwebdev.blogspot.in/2016/11/tomcat-catalina.html

Sunday, May 31, 2015

Ubantu - Devloper Software Regarding Command

Basic Command:

To Inatall dpkg
sudo dpkg -i <softwareName.deb>

Extract Tar
sudo tar xzvf <softwareName.tar.*>

Permissio To user
1)chown -R <UserName> <Folder Name> →owner read permission is roll back and write permission→super user command
2.1)chmod -R 777 <Folder Name> → full permission → super user command
2.2)sudo chmod -R 777 *

To Remove Folder
echo $PATH
sudo rm -rf <folderName/filename>

Super User Login
sudo -i

To Exit Super User Login
exit

To See Hidden Folder
ctrl+H

To Move File
sudo mv <fileName> <file Location>

Refresh bashrc(same for .profile)
. ~/.bashrc

Remove dpkg
$ sudo apt-get remove softwarename
$ sudo apt-get --purge remove softwarename

Record my Desktop:\
Avaiable in ubantu store.
sudo apt-get install gtk-recordmydesktop

JDK 7
$ sudo apt-add-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java7-installer
$ java -version
   java version "1.7.0_56"

Now set environment variables for the installed JAVA version.
$ sudo apt-get install oracle-java7-set-default

OR Direct install from oracle site

  http://www.wikihow.com/Install-Oracle-Java-JDK-on-Ubuntu-Linux

Rabbit mq
http://bobcravens.com/2014/02/rabbitmq-install-unbuntu/
sudo apt-get remove rabbitmq-server
sudo apt-get install python-software-properties
sudo add-apt-repository "deb http://www.rabbitmq.com/debian/ testing main"
wget http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
sudo apt-key add rabbitmq-signing-key-public.asc
sudo apt-get update
sudo apt-get install rabbitmq-server -y
sudo service rabbitmq-server start
sudo rabbitmq-plugins enable rabbitmq_management
sudo service rabbitmq-server restart
http://localhost:15672/
uname : guest
pwd : guest

SVN: http://tutorialforlinux.blogspot.in/2013/08/tutorial-install-rabbitvcbas-in-ubuntu.html

Hamachi
1)sudo apt-get install lsb
2)sudo add-apt-repository ppa:webupd8team/haguichi
3)sudo apt-get update && sudo apt-get install haguichi
4)Download .deb file as per pc
[LogMeIn Hamachi for Linux (Beta) command line version - > learn more ]
https://secure.logmein.com/labs/#HamachiforLinux
https://www.vpn.net/linux
5)serach "Haguichi" and run
6)connect
7)join network from menu client->join network
username:
pwd:
For more read :
https://help.ubuntu.com/community/Hamachi

Myslq

Remove Mysql in Linux:
sudo apt purge mysql-*
sudo apt autoremove

Install Mysql in Linux:
sudo apt-get install mysql-server
sudo apt-get install mysql-client

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root@1234';
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON *.* TO 'administrator'@'localhost' IDENTIFIED BY 'root@1234';

sudo apt-get install mysql-workbench

Allow access in network mysql
1)sudo /etc/init.d/mysql stop
2)sudo chmod 777 /etc/mysql/my.cnf
3)comment below lines
# localhost which is more compatible and is not less secure.
# bind-address  = 0.0.0.0
4)sudo chmod 0644 /etc/mysql/my.cnf
5)sudo /etc/init.d/mysql start

Wavemaker installation
wminstallers.s3.amazonaws.com/6.7.0+RELEASE/wavemaker-6.7.0.RELEASE.exe

Desktop Launcher
sudo gedit /usr/share/applications/appname.desktop
[Desktop Entry]
Version=6.7.0
Name=software name
Type=Application
Exec=bin path
Terminal=false
Icon=icon path which show in software
Name[en]=english name
Categories=Utility;Application;

Tomcat
http://tomcat.apache.org/download-70.cgi
$ cd /opt
$ sudo tar -xvzf ~/Downloads/apache-tomcat-*.tar.gz
$ sudo gedit ~/.bashrc
   # environment variable for tomcate
   export CATALINA_HOME=/opt/apache-tomcat-7.0.59
   # environment variable for JAVA
   export JAVA_HOME=/usr/lib/jvm/java-7-oracle
make sure you have set the environment variable properly.
To Start Tomcat :
   $sudo $CATALINA_HOME/bin/startup.sh
    Tomcat should be started.
To Stop Tomcat :
   $sudo $CATALINA_HOME/bin/shutdown.sh
    Tomcat should be shutdown.

Eclipse
https://eclipse.org/downloads/
open terminal
$ cd /opt
$ sudo tar -zxvf ~/Downloads/eclipse-*.tar.gz
sudo gedit /usr/share/applications/eclipse.desktop

[Desktop Entry]
Name=Eclipse 4
Type=Application
Exec=/opt/eclipse/eclipse
Terminal=false
Icon=/opt/eclipse/icon.xpm
Comment=Integrated Development Environment
NoDisplay=false
Categories=Development;IDE;
Name[en]=Eclipse 

Skype installation
1)sudo apt-get remove skype skype-bin
2)rm -rf ~/.skype
3)sudo apt-get update;
4)sudo apt-get install skype

iReport Desktop
open terminal
$ cd /opt
sudo tar -zxvf ~/Downloads/SW/iReport-5.6.0.tar.gz
sudo gedit /usr/share/applications/ireport.desktop

[Desktop Entry]
Version=5.5
Name=iReport
Comment=JasperReport
Exec=/opt/iReport-5.6.0/bin/ireport
Icon=/opt/iReport-5.6.0/bin/document.ico
Terminal=false
Type=Application
Categories=Utility;Application;

Postgresql
http://www.postgresql.org/download/linux/ubuntu/
sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main"
https://wiki.postgresql.org/wiki/Apt
sudo apt-get install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install postgresql-9.4 pgadmin3