HTTP ApiServer implemented with ServerSocket of Java using mutlti-threading
These instructions will get you a copy of the project up and running on your local machine for testing purposes.
It assumes the following are already installed on your system
- JDK 1.8+
- Maven 3.0+
- cURL 7.53+
Check whether the following are already installed on your system or not
-
Operating System architecture
- Open command prompt on your OS as administrator by going to Start -> Run
- Enter
cmd.exe
and hit enter. The command prompt opens up - Type
echo %PROCESSOR_ARCHITECTURE%
and hit enter - This will return
x86
on 32-bit systems andAMD64 (or IA64)
on 64-bit systems.
-
Java Installation
- Open command prompt on your OS as administrator by going to Start -> Run
- Enter
cmd.exe
and hit enter. The command prompt opens up - Type
java -version
and hit enter - It should display the following output
java version "1.8.0" Java(TM) SE Runtime Environment (build 1.8.0-b132) Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
-
Maven Installation
-
- Open command prompt on your OS as administrator by going to Start -> Run
- Enter
cmd.exe
and hit enter. The command prompt opens up - Open command prompt on your OS as administrator
- Type
mvn -version
and hit enter - It should display the following output
**Apache Maven 3.3.9 ** (bb52d8502b132ec0a5a3f4c09453c07478323dc5;20157+05:30) Maven home: F:\Softwares\Software Tools\apache-maven-3.3.9 Java version: 1.8.0, vendor: Oracle Corporation Java home: I:\Program Files\Java\jdk1.8.0\jre Default locale: en_GB, platform encoding: Cp1252 OS name: "windows 8", version: "6.2", arch: "amd64", family: "dos"
-
-
cURLInstallation
- Open command prompt on your OS as administrator
- Type
curl --version
and hit enter - It should display the following output
curl 7.46.0 (x86_64-pc-win32) libcurl/7.46.0 OpenSSL/1.0.2e zlib/1.2.8 WinIDN libssh2/1.6.0 Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtsp scp sftp smtp smtps telnet tftp Features: AsynchDNS IDN IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL libz
-
Java
- Download the latest version of JDK from this link based on your OS architecture
- Install the downloaded package
- Note down the JDK installation directory. It should be like
<Drive>:\Program Files\Java\jdk1.8.0
or<Drive>:\Program Files (x86)\Java\jdk1.8.0
based on your OS architecture - Right click on My Computer -> Properties -> Advanced System Settings
- Click on Advanced Tab -> Environment Variables
- Make a new entry in System Variables with Variable Name as
JAVA_HOME
and Variable Value as your JDK installation directory based on your OS architecture - Verify JDK installation
-
Maven
- Download the latest distribution of Apache Maven from this link
- Unzip the downloaded package to a location such as
<Drive>:\Program Files\Apache\maven
or<Drive>:\Program Files (x86)\Apache\maven
based on your OS architecture or any other location of your choice. Note down the path where you have unzipped your maven distribution - Right click on My Computer -> Properties -> Advanced System Settings
- Click on Advanced Tab -> Environment Variables
- Make a new entry in System Variables with Variable Name as
M2_HOME
and Variable Value as maven location on your system from the previous step - Make a new entry in System Variables with Variable Name as
MAVEN_HOME
and Variable Value as maven location on your system from the previous step - Verify Maven installation
-
cURL
- Download the latest installer of cURL from this link
- Click on the downloaded installer and start installation by following the on screen steps in the instalaction wizard
- Once the installation is completed, verify cURL installation
- Download this project on your local system as a .zip package
- Unzip the package on to your local drive. Remember the path to which you unzipped the project
- Open command prompt and type
cd <path to downloaded package>
. Hit enter - Type
<drive letter>:
and hit enter. You will now be in the directory where the package is present - Type
cd ApiServer
to navigate inside the project - Once you are inside the project, enter
mvn clean install
and hit enter. Maven will start gathering the dependencies, compile the project and build it into the target packaging. Note : The first time you run the maven build it will take some time to download the required dependencies. Once build is completed successfully, you will get a message at the end of the console output ofmvn clean install
[INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 5.644 s [INFO] Finished at: 2017-04-13T23:01:20+05:30 [INFO] Final Memory: 19M/89M [INFO] ------------------------------------------------------------------------
- Type
cd ..
at the command prompt to go back to the parent directory - Type
cd target
to go into the directory where Maven has built the packaging of the project with the required dependencies into a jar file with the name ApiServer-0.0.1-SNAPSHOT.jar - Type
java -jar ApiServer-0.0.1-SNAPSHOT.jar <port number>
to start the API Server. The port number argument is optional. If no argument is provided, the API Server will start on port 80 by default
- Maven - Dependency Management
- Anirban Das - Initial work - anirbandas18
- Backend-End hiring assignment for Dipper