❌

Reading view

There are new articles available, click to refresh the page.

React -Router

Understanding Routes

React- Router is used for render the components depends on URL without reloading the browser page. It navigates a page to another page without page reloads. we can use router in react project, first we install the react-router-dom package from react.

Then, access the router using

import {BrowserRouter,Router,Routes} from 'react-router-dom';

after that we use link to diplay the browser using Link instead <a href=''> in react.

so,

import {BrowserRouter,Router,Routes,Link} from β€˜react-router-dom’;

example for using Link and routes:

Using Links:

  '/' is the root page it display default home page

    <Link to='/'>Home</Link>
    <Link to='/about'>About</Link>
    <Link to='/contact'>Contact</Link>

}/> }> }/>

Using Routes:

<Browser Router>
<Router>
<Routes path='/' element={<Home/>}/>
<Routes path='/about' element={<About/>}>
<Routes path='/contact' element={<Contact/>}/>
</Router>
</Browser Router>

React -Router

Understanding Routes

React- Router is used for render the components depends on URL without reloading the browser page. It navigates a page to another page without page reloads. we can use router in react project, first we install the react-router-dom package from react.

Then, access the router using

import {BrowserRouter,Router,Routes} from 'react-router-dom';

after that we use link to diplay the browser using Link instead <a href=''> in react.

so,

import {BrowserRouter,Router,Routes,Link} from β€˜react-router-dom’;

example for using Link and routes:

Using Links:

  '/' is the root page it display default home page

    <Link to='/'>Home</Link>
    <Link to='/about'>About</Link>
    <Link to='/contact'>Contact</Link>

}/> }> }/>

Using Routes:

<Browser Router>
<Router>
<Routes path='/' element={<Home/>}/>
<Routes path='/about' element={<About/>}>
<Routes path='/contact' element={<Contact/>}/>
</Router>
</Browser Router>

Install postgres & pgadmin

sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh

To manually configure the Apt repository, follow these steps:

sudo apt install curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc –fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
sudo sh -c β€˜echo β€œdeb

[signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc]

https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main” > /etc/apt/sources.list.d/pgdg.list’
sudo apt update
sudo apt -y install postgresql

sudo -i -u postgres

psql

\q

createdb my_pgdb

psql -d my_pgdb

\conninfo

After the we have download pgadmin using cmd :

#
# Setup the repository
#

# Install the public key for the repository (if not done previously):
curl -fsS https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /usr/share/keyrings/packages-pgadmin-org.gpg

# Create the repository configuration file:
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/packages-pgadmin-org.gpg] https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'

#
# Install pgAdmin
#

# Install for both desktop and web modes:
sudo apt install pgadmin4

# Install for desktop mode only:
sudo apt install pgadmin4-desktop

# Install for web mode only:
sudo apt install pgadmin4-web

# Configure the webserver, if you installed pgadmin4-web:
sudo /usr/pgadmin4/bin/setup-web.sh

After tat setting password for pgadmin

sudo -i -u postgres

psql

\password postgres

Enter new pasword :

Enter it again


Reference : https://www.postgresql.org/download/linux/ubuntu/

https://www.pgadmin.org/download/pgadmin-4-apt/


Install postgres & pgadmin

sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh

To manually configure the Apt repository, follow these steps:

sudo apt install curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc –fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
sudo sh -c β€˜echo β€œdeb

[signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc]

https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main” > /etc/apt/sources.list.d/pgdg.list’
sudo apt update
sudo apt -y install postgresql

sudo -i -u postgres

psql

\q

createdb my_pgdb

psql -d my_pgdb

\conninfo

After the we have download pgadmin using cmd :

#
# Setup the repository
#

# Install the public key for the repository (if not done previously):
curl -fsS https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /usr/share/keyrings/packages-pgadmin-org.gpg

# Create the repository configuration file:
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/packages-pgadmin-org.gpg] https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'

#
# Install pgAdmin
#

# Install for both desktop and web modes:
sudo apt install pgadmin4

# Install for desktop mode only:
sudo apt install pgadmin4-desktop

# Install for web mode only:
sudo apt install pgadmin4-web

# Configure the webserver, if you installed pgadmin4-web:
sudo /usr/pgadmin4/bin/setup-web.sh

After tat setting password for pgadmin

sudo -i -u postgres

psql

\password postgres

Enter new pasword :

Enter it again


Reference : https://www.postgresql.org/download/linux/ubuntu/

https://www.pgadmin.org/download/pgadmin-4-apt/


Eclipse closes automatically when Using β€˜System.out.println’

I’m experiencing an issue with Eclipse where it closes automatically when I use β€˜System.out.println’.

Environment :
Eclipse Version: eclipse 2024-03 is the latest version of Eclipse today I reinstalled it.
I downloaded Eclipse from the official Eclipse Foundation website at Eclipse Downloads | The Eclipse Foundation 1.

JDK version : java 22.0.1 2024-04-16
Javaβ„’ SE Runtime Environment (build 22.0.1+8-16)
Java HotSpotβ„’ 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)

Operating System: Ubuntu Ubuntu 22.04.4 LTS

Problem Description: Whenever I run a simple Java program that uses System.out.println. Eclipse hung and closed automatically without getting any error messages.

How i fix this issue

I fix this issue

Hi everyone,

I recently encountered a problem with Eclipse. when I upgraded Ubuntu 20 to Ubuntu 22 then some applications did not work properly . After some troubleshooting, I discovered that switching from Wayland to X11 resolved the issue. Here’s how you can do it:

How to Switch from Wayland to X11 on Ubuntu

If you’re experiencing issues with Wayland and want to switch back to X11, follow these steps:

Turn off Wayland and switch back to X11.

  1. Log out of Ubuntu.
  2. Start to log in again and click the icon that has appeared at the bottom right of the screen – that gives you the option to disable Wayland.
  3. Switch back to Xorg.

Switching to X11 fixed the issues I was having, so I hope this helps anyone experiencing similar problems. Let me know if you have any questions or need further assistance!

Eclipse closes automatically when Using β€˜System.out.println’

I’m experiencing an issue with Eclipse where it closes automatically when I use β€˜System.out.println’.

Environment :
Eclipse Version: eclipse 2024-03 is the latest version of Eclipse today I reinstalled it.
I downloaded Eclipse from the official Eclipse Foundation website at Eclipse Downloads | The Eclipse Foundation 1.

JDK version : java 22.0.1 2024-04-16
Javaβ„’ SE Runtime Environment (build 22.0.1+8-16)
Java HotSpotβ„’ 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)

Operating System: Ubuntu Ubuntu 22.04.4 LTS

Problem Description: Whenever I run a simple Java program that uses System.out.println. Eclipse hung and closed automatically without getting any error messages.

How i fix this issue

I fix this issue

Hi everyone,

I recently encountered a problem with Eclipse. when I upgraded Ubuntu 20 to Ubuntu 22 then some applications did not work properly . After some troubleshooting, I discovered that switching from Wayland to X11 resolved the issue. Here’s how you can do it:

How to Switch from Wayland to X11 on Ubuntu

If you’re experiencing issues with Wayland and want to switch back to X11, follow these steps:

Turn off Wayland and switch back to X11.

  1. Log out of Ubuntu.
  2. Start to log in again and click the icon that has appeared at the bottom right of the screen – that gives you the option to disable Wayland.
  3. Switch back to Xorg.

Switching to X11 fixed the issues I was having, so I hope this helps anyone experiencing similar problems. Let me know if you have any questions or need further assistance!

this keyword

  • this is a java keyword this keyword refers to current object of the same class
  • this keyword helps to differentiate between local variable and global instance variable
  • we cannot use this keyword inside static context. [static method or static block].
  • this only used for object specific.
class Shop
{
static String shopName ="Updatez";
int price, discount; // non-static variable
public static void main(String args[])
{
Shop product = new Shop();
product.price =1000;
product.discount =10;

s.sell(); // method calling
}

void sell()
{
int discount = 30; // local variable
System.out.println(discount);30
System.out.println(this.price);
System.out.println(this.discount);
}
}

output:
30
1000
10

we cannot use this keyword inside the static method and also a main method


Scanner |Java

import java.util.Scanner;

Scanner sc = new Scanner(System.in);

A simple text scanner that can parse primitive types and strings using regular expressions.
A Scanner breaks its input into tokens using a delimiter pattern, which by default matches whitespace. The resulting tokens may then be converted into values of different types using the various next methods.

Scanner sc = new Scanner(System.in);
System.out.println("Enter the value:");
int value =sc.nextInt();
System.out.println(value);
  • int –> nextInt()
  • long –>nextLong()
  • short –>nextShort()
  • float –> nextFloat()
  • double –> nextDouble()
  • boolean –> nextBoolean()
  • String –> nextLine() & next()

reference:https://docs.oracle.com/javase/8/docs/api/java/util/Scanner.html

Fields in Java

Fields are categorized by various data types in java.

Methods -> set of Instructions with a name for a specific task.

Data types in java :

Java programming language is statically typed, means all variables must first be declared before being used.

  • Primitive
  • Non-Primitive

Primitive Data types in java :

Fields | global variables

  • class specific fields
  • object specific fields

Field is a data member of a class. Unless specified otherwise, a field is not static.

  • static variables
  • non-static variables

Static variables:

  • common variables for all objects
  • static members will have only one copy in memory. but static is not constant.
  • values will change.
  • static varibles depends on whole class. so, its a class specific variables.
static String owner_name ="Elavarasu";

Non-static variables: | Instance [object specific]

  • specific to each objects.
  • non-static members will have multiples copies in memory
  • it depends only a object. so it is object specific.
String employee = "name";

Source-Code:


Reference : https://www.shiksha.com/online-courses/articles/data-types-in-java-primitive-and-non-primitive-data-types/

this keyword

  • this is a java keyword this keyword refers to current object of the same class
  • this keyword helps to differentiate between local variable and global instance variable
  • we cannot use this keyword inside static context. [static method or static block].
  • this only used for object specific.
class Shop
{
static String shopName ="Updatez";
int price, discount; // non-static variable
public static void main(String args[])
{
Shop product = new Shop();
product.price =1000;
product.discount =10;

s.sell(); // method calling
}

void sell()
{
int discount = 30; // local variable
System.out.println(discount);30
System.out.println(this.price);
System.out.println(this.discount);
}
}

output:
30
1000
10

we cannot use this keyword inside the static method and also a main method


Scanner |Java

import java.util.Scanner;

Scanner sc = new Scanner(System.in);

A simple text scanner that can parse primitive types and strings using regular expressions.
A Scanner breaks its input into tokens using a delimiter pattern, which by default matches whitespace. The resulting tokens may then be converted into values of different types using the various next methods.

Scanner sc = new Scanner(System.in);
System.out.println("Enter the value:");
int value =sc.nextInt();
System.out.println(value);
  • int –> nextInt()
  • long –>nextLong()
  • short –>nextShort()
  • float –> nextFloat()
  • double –> nextDouble()
  • boolean –> nextBoolean()
  • String –> nextLine() & next()

reference:https://docs.oracle.com/javase/8/docs/api/java/util/Scanner.html

Fields in Java

Fields are categorized by various data types in java.

Methods -> set of Instructions with a name for a specific task.

Data types in java :

Java programming language is statically typed, means all variables must first be declared before being used.

  • Primitive
  • Non-Primitive

Primitive Data types in java :

Fields | global variables

  • class specific fields
  • object specific fields

Field is a data member of a class. Unless specified otherwise, a field is not static.

  • static variables
  • non-static variables

Static variables:

  • common variables for all objects
  • static members will have only one copy in memory. but static is not constant.
  • values will change.
  • static varibles depends on whole class. so, its a class specific variables.
static String owner_name ="Elavarasu";

Non-static variables: | Instance [object specific]

  • specific to each objects.
  • non-static members will have multiples copies in memory
  • it depends only a object. so it is object specific.
String employee = "name";

Source-Code:


Reference : https://www.shiksha.com/online-courses/articles/data-types-in-java-primitive-and-non-primitive-data-types/

Features of Java

1. Java is simple:

Java is a simple programming language. Because syntax is derived from C & C++ language. Java has removed some complex topics like Pointers, Operator Overloading, and Multiple Inheritance explicit memory allocation. Java has an Automatic Garbage Collection.

2. Java is Robust :

  • Java is Robust which means Strong | Reliable
  • It uses strong memory management.
  • Java provides automatic garbage collection which runs on the JVM to get rid of objects that are not being used by a Java application anymore.
  • There is exception handling and the type checking mechanism in Java
  • It is developed in such a way that it puts a lot of effort into checking errors as early as possible, which is why the Java compiler can detect even those errors that are not easy to detect by another programming language.

3. Java is Platform Independent :

Operating System – Os is interface between Human Being and Machine. Platform is nothing but Processor + Os .

  • Java has two level translation – Compilation and Interpretation.
  • Java Development Kit – JDK
  • Compiler is the part of jdk. Error checking mechanism is also present in jdk.
  • First jdk will check the error. If in case error is present in the code compilation is not allowed. So translator need error free file for translation process.
  • .Java file is converted into .classfile using JDK. It will check whole file into single run. Classfile is otherwise called Bytecode.
  • This byte code or .Classfile is Platform Independent code. Because .classfile is common for all the Platform(Os).
  • Java virtual machine – JVM . Jit compiler is part of JVM
  • JVM is part of JRE – Java Runtime Environment.
  • .Class file is converted into binary code using interpreter. It will check line by line. Binary code is otherwise known as Machine code.
  • This compilation is Platform Dependent conversion.
  • Jit compiler : Just in time compiler. Converting Byte code into Binary code.

Reference :

https://www.geeksforgeeks.org/java

https://www.javatpoint.com/features-of-java

Features of Java

1. Java is simple:

Java is a simple programming language. Because syntax is derived from C & C++ language. Java has removed some complex topics like Pointers, Operator Overloading, and Multiple Inheritance explicit memory allocation. Java has an Automatic Garbage Collection.

2. Java is Robust :

  • Java is Robust which means Strong | Reliable
  • It uses strong memory management.
  • Java provides automatic garbage collection which runs on the JVM to get rid of objects that are not being used by a Java application anymore.
  • There is exception handling and the type checking mechanism in Java
  • It is developed in such a way that it puts a lot of effort into checking errors as early as possible, which is why the Java compiler can detect even those errors that are not easy to detect by another programming language.

3. Java is Platform Independent :

Operating System – Os is interface between Human Being and Machine. Platform is nothing but Processor + Os .

  • Java has two level translation – Compilation and Interpretation.
  • Java Development Kit – JDK
  • Compiler is the part of jdk. Error checking mechanism is also present in jdk.
  • First jdk will check the error. If in case error is present in the code compilation is not allowed. So translator need error free file for translation process.
  • .Java file is converted into .classfile using JDK. It will check whole file into single run. Classfile is otherwise called Bytecode.
  • This byte code or .Classfile is Platform Independent code. Because .classfile is common for all the Platform(Os).
  • Java virtual machine – JVM . Jit compiler is part of JVM
  • JVM is part of JRE – Java Runtime Environment.
  • .Class file is converted into binary code using interpreter. It will check line by line. Binary code is otherwise known as Machine code.
  • This compilation is Platform Dependent conversion.
  • Jit compiler : Just in time compiler. Converting Byte code into Binary code.

Reference :

https://www.geeksforgeeks.org/java

https://www.javatpoint.com/features-of-java

Git Commands

  • git clone
  • git add
  • git commit
  • git push
  • git pull
  • git branch
  • git checkout
  • git status

git clone remote

to create new repository in github cloud , then create a local repo and clone 2 repositories using git clone remote (repo link).

git add filename
git add .

to add a single file using git add and add all the files which present in the current repo the use git add . | . represent add all the files.

git commit -m "message"

commit the added file using git commit and put some mesagges about the file using -m ” ” .

some ideas of commit messages are available in below mentioned link.

Reference : conventional commit.org | https://www.conventionalcommits.org/en/v1.0.0/

git rm --cached filename
if incase want to remove the added file use git remove
git rm --cached -f filename
-f --> forcefully remove the file.
git push

push the commited file from the local to cloud repo using git push. it will push the file to remote repository.

git pull 

when u need to change or edit or modify the remote file first you will pull the file to local repository from remote using git pull.

git branch 
Branch means where will you store the files in git remote.git branch is to specify the branch name it will push the file to current remote branch.

git checkout -b "branchname"
to create a new branch.

git checkout branchname
check the created branch or new branch

git branch -M branchname
to modify or change the branch name

git branch -a
to listout all branches.
git status
check all the status of previously used command like know the added file is staged or unstaged

Reference : https://www.markdownguide.org/cheat-sheet/

markdown cheathseet for readme file

Reference : conventional commit.org | https://www.conventionalcommits.org/en/v1.0.0/

for commit messages.

❌