Running Java Program

Compile and Execute Java Programs or Projects into windows.

Editors

  • Notepad(Default with Windows), Notepad++ , VSCode
  • Simple
  • Code cannot be debugged
  • Easy to use.
  • Better for Small Programs
  • Some Plugins are required for intellisense

IDE

The term “IDE” comes from Integrated Development Environment. It is intended as a set of tools that all work together: text editor, compiler, build or make integration, debugging, etc. Virtually all IDEs are tied specifically to a language or framework or tightly collected set of languages or frameworks. Some examples: Visual Studio for .NET and other Microsoft languages, RubyMine for Ruby, IntelliJ for Java, XCode for Apple technologies.

An editor is simply that, a tool that is designed to edit text. Typically they are optimized for programming languages though many programmer’s text editors are branching out and adding features for non-programming text like Markdown 124 or Org Mode 104. The key here is that text editors are designed to work with whatever language or framework you choose

Watch below video for Eclipse Installation and Running Your First Java Program.

Running Java Program Eclipse

Java Installation

Step 1: Download JDK

Step 2: Watch Video for Installation

Java Servlets

Servlet technology is used to create web application (stays at server side and generates a dynamic web page).

Servlet technology is robust and scalable because of java language. Before Servlet, CGI (Common Gateway Interface) scripting language was common as a server-side programming language. However, there were many disadvantages to this technology. We have discussed these disadvantages below.

There are many interfaces and classes in the Servlet API such as Servlet, GenericServlet, HttpServlet, ServletRequest, ServletResponse, etc.

Software Required:

  1. Java JDK. (Version 7 or Above)
  2. Tomcat Apache Server (7.0 is preferred).

Check the below video for setup of

Java Servlet Execution and Enviromnet Setup for Windows Base OS.

Above video is demonstrated for the purpose of learning and education of B.C.A. and BSC.IT. Students of Saurashtra University.

JDBC with MySQL

JDBC stands for Java Database Connectivity is quite a way that helps Java Users to interact with many versatile Database. I am going to show you the connectivity for JDBC with MySQL because both are Open Source in terms of using it.

Software Requried:

  • Java JDK.
  • Xampp or any other application that let’s you interact with phpmyadmin to create a database.
  • MySQL Connector for JDBC Connectivity.

Steps for JDBC setup

  • Download and Install Xampp or Laragon.
  • Download MySQL Connector and follow below steps.
  • Extract the file.
  • Paste the mysqlconnector.jar [Your Drive]\Java\jdk[version]\jre\lib\ext
  • Right Click on mysqlconnector.jar and GOTO properties.
  • In Properties Look for Unblock Button, If not found than go for Coding.

Note: [Your Data] Square Brackets are your Environment Setup.

Source Code:

imort java.sql.*;
class JDBCEX {
    Connection con;
    Statement st;
    ResultSet rs;
    public JDBCEX() { //Constructor
        try {
            Class.forName("com.mysql.jdbc.Driver");
            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/[YourDatabase]"); 
            //There should be a database named as test in your phpmyadmin.
            System.out.println("Connected Successfully");
            st = con.createStatement();
            rs = st.executeQuery("Select * from [YourTable]"); 
            //There should be a table named as test1 in your database test1.
            while (rs.next()) {
              //Keep Some records in table to run this code.
              System.out.println("RNO : " + rs.getInt(1) + "\nNAME : " + rs.getString(2) + "\nAddress : " + rs.getString(3) + "\nEmail : " + rs.getString(4) + "\n");
            }
        } catch (Exception e) {
            System.out.println(e);
        }
    }
    public static void main(String args[]) {
        JDBCEX test = new JDBCEX();
    }
}
JDBC MySQL Integration