Giter Club home page Giter Club logo

jeeshop's Introduction

JEEShop

Just a simple JEE shop I made as a proyect for my school to get confident with servlets and jsp.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

First and foremost, this is a tutorial for Arch-based distro's users, if it is not your case you will need to learn how to install the packages for your distros. The rest of the tutorial is the same.

JDK 8 or higher

I hope you did not need help to install this. Anyway here is the archwiki page about java. If you are not familiar with JDK8 new features please check this CheatSheet out.

In my case I will choose openJDK11 because is the LTS version of the JDK.

	sudo pacman -Syu
	
	sudo pacman -S jdk11-openjdk

Now we need to set the JAVA_HOME in my case I will set it for all users so I just add this at the end of /etc/profile

	
	#JAVA
	
	export JAVA_HOME="/usr/lib/jvm/java-11-openjdk"

	export PATH=$JAVA_HOME/bin:$PATH

In case you would prefer to set the JAVA_HOME only for your user just add the same lines on ~/.bash_profile If you want to know more about the bash configuration files please check the wiki

After that restart your machine.

	reboot

Eclipse

In order to run this software you will need to install Eclipse IDE for java EE developers. You can not install several eclipse versions because they will conflict so if it is your case you will need to find the way to keep both. You cant get more info here.

	sudo pacman -Syu

	sudo pacman -S eclipse-jee

MariaDB

MariaDB is nowdays the default relational database solution for Arch Linux so it will be my choice.

	sudo pacman -Syu mariadb mariadb-clients libmariadbclient

	sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

	sudo systemctl start mysqld.service

	sudo systemctl enable mysqld.service
	

Now we need to create owr db. First of all we will log into owr mariadb server.

	sudo mysql -u root

So go ahead and create the shop's db and a new user.

	CREATE DATABASE shop;
	GRANT ALL ON shop.* TO 'shopadmin'@localhost IDENTIFIED BY 'shop';
	FLUSH privileges;
	exit
	

We can now login with this new user which have all privileges on that bd.

	mysql -u shopadmin -p

Let's create the tables we need now.

	
	use shop
	
	CREATE TABLE IF NOT EXISTS customers(
	id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
	name VARCHAR(10) NOT NULL,
	password VARCHAR(20) NOT NULL);
	
	CREATE TABLE IF NOT EXISTS products (
	idProduct INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 
	description VARCHAR(40) NOT NULL, 
	price FLOAT(7,2) NOT NULL);
	
	CREATE TABLE IF NOT EXISTS bills (
	id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
	client_id INT NOT NULL,
	purchase_date DATETIME NOT NULL);
	
	CREATE TABLE IF NOT EXISTS bill_lines(
	id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
	bill_id INT NOT NULL,
	product_id INT NOT NULL,
	units INT NOT NULL CHECK( UNITS > 0));
	

Tomcat9

Tomcat is the server that will allow us to execute owr projet.In order to install Tomcat just download it form here or use wget.

If you have download the tar.gz version execute this commands to extract it and move it to your home directory.

	cd ~/Downloads
	
	tar -xvzf apache-tomcat-9.x.xx.tar.gz
	
	mv apache-tomcat-9.x.xx ~/Tomcat	

Now we need to change the file permissions under the directory bin to allow Eclipse to execute Tomcat

	sudo chmod +x ~/Tomcat/bin/*

This Tomcat installation is only for development and testing purposes, so if you want to use Tomcat to deploy your JavaEE application you will need to follow a few more steps that I will add on an md file on the future.

Libraries

  • MySQL's Connector/J - The official connector for MySQL database which is compatible with MariaDB. More info here
  • servlet-api.jar - Included with Tomcat (under the directory lib)
  • jsp-api.jar - Included with Tomcat (under the directory lib)

Get a copy

For some reason I can not just import this project with the git tool that eclipse provides. So I just created a new Dynamic Web Project (Dynamic web module 4.0 and named JEEShop), then I deleted the MANIFIEST.MF and I open my terminal and I start a git repository on the proyect's directory.

	
	cd eclipse-workspace/JEEShop
	
	git init
	
	git remote add origin https://github.com/seniorglez/JEEShop.git
	
	git pull origin master
	

Now we have the full project but eclipse will not show the files we just pull, we just need to refresh the project. All we need to do is right click on the project and select Refresh (or press F5).

Running it

Built With

  • Eclipse - The IDE I used
  • Tomcat - The Java Servlet and JavaServer Pages implementation
  • MariaDB - The relational database solution

Contributing

Feel free to fork it and made pull request if I made something wrong but please keep in mind that it is just an example of servlet and jsp use.

Authors

  • Diego Dominguez Twitter: DGlez1111

License

JEEShop is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

JEEShop is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with JEEShop. If not, see https://www.gnu.org/licenses/

GPL3 or later

Why GPL3 and not AGPL3?

I used GPL3 license because this is just an example of app and it will never turn on a real app because if you want to develop an real one you will prefer to use a framework like Hibernate. But if you are developing a server side application under GPL3 means that this app will provide HTML and not an executable program so another person could take your code, make changes on it and not publish his own version. If you want to keep your application full free please use AGPL3 instead of GPL3.

jeeshop's People

Contributors

seniorglez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

infasyskey

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.