Enable WIFI ADAPTER Monitor Mode in Kali Linux

Connect the WIFI adapter and add it in VirtualBox USB Settings TP-Link TL-WN725N 150Mbps Wireless N Nano USB Adapter https://www.amazon.in/gp/product/B008IFXQFU Check the Adapter Chippet lsusb Bus 001 Device 002 : ID 2357 : 0109 TP-Link TL-WN823N v2 / v3 [Realtek RTL8192EU] Bus 001 Device 001 : ID 1 d6b: 0002 Linux Foundation 2 . 0 root hub Bus 002 Device 002 : ID 80 ee: 0021 VirtualBox USB Tablet Bus 002 Device 001 : ID 1 d6b: 0001 Linux Foundation 1 . 1 root hub Find Appropriate Driver for Realtek RTL8192EU from GitHub https://github.com/clnhub/rtl8192eu-linux Install the dependencies sudo apt install linux-headers-generic build-essential dkms git Clone the Driver git clone https://github.com/clnhub/rtl8192eu-linux.git Configure the Architecture and Monitor Mode Open MakeFile in Text Editor or Nano If you're using a different architecture than x86, the set (MakeFile) CONFIG_PLATFORM_I386_PC = n set your architecture CONFIG_PLATFORM_ARM_AARCH64...

Understanding Common Compile Time Errors in Java

What is an Error in Program?

  • Errors are mistakes in a program that prevents it from working condition.
  • Three types of error
    • Compile Time Error
    • Logical Error
    • Runtime Error
  • This document discusses the compile time and logical errors.

Unresolved compilation problem

  • Exception in thread "main" java.lang.Error: Unresolved compilation problem
  • This happens when the public class keyword used other than Java File Name
  • Example: Java File Name: Employee.java but public class is EmployeeTest
  • Solution: File must be renamed as EmployeeTest.java
class Employee {
    private String name;
    public Employee(String name) {
        this.name = name;
    }
    public String toString() {
        return "Employee [name=" + name + "]";
    }
}
public class EmployeeTest {
    public static void main(String[] args) {
        System.out.println(new Employee("Kumar").toString());
    }
}

The method is undefined

  • Reason-1: There might be a spelling mistake in the method name.
  • Reason-2: The method might not have been created in class.
  • Example
class Employee {
    private String name;
    public Employee(String name) {
        this.name = name;
    }
    public String getName() {
        return this.name;
    }
}
public class EmployeeTest {
    public static void main(String[] args) {
        Employee employee = new Employee("Kumar");
        // Spelling mistake in method name
        System.out.println(employee.getNaem());
    }
}

Syntax error, insert ";" to complete Statement

  • Check the Line Number displayed in Error Message
  • Add a "semicolon;" at the end of that statement
public class EmployeeTest {
    public static void main(String[] args) {
        // Semicolon (;) missing
        System.out.println("Welcome to Java") 
    }
}

Syntax error on token ",", ; expected

  • Reason - comma(,) was used instead of a semicolon (;)
  • Example
public class EmployeeTest {
    public static void main(String[] args) {
        // should be for (int i = 0; i < 3; i++) 
        for (int i = 0, i < 3; i++) { 
            System.out.println(i);
        }
    }
}

String literal is not properly closed by a double-quote

  • Reason: The starting is not properly closed with a double quote
import java.time.LocalDate;
public class EmployeeTest {
    public static void main(String[] args) {
        //should be closed with a double quote
        System.out.println("Sample program to display current date: ); 
        System.out.println(LocalDate.now());
    }
}

Unreachable Code or Statement

class Employee {
    private String name;
    public Employee() {}
    public Employee(String name) {
        this.name = name;
    }
    public String concatUpper(String message) {
        String newStr = message + this.name;
        return newStr;
        // should be before return
        newStr.toUpperCase(); 
    }
}
public class EmployeeTest {
    public static void main(String[] args) {
        Employee employee = new Employee("Kumar");
        System.out.println(employee.concatUpper("Welcome"));
    }
}

Logical Mistake: Using Logical Operators

  • Write a Java Program for checking the given name has only an alphabets and minimum 3 characters
public class EmployeeTest {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String name = input.nextLine();
        // ! should be used for matches
        if (name.matches("[a-z]+") && name.length() < 3) { 
            System.out.println("Invalid Input");
        } else {
            System.out.println(name);
        }
    }
}

Comments