Posts Tagged: "Java"

Java – JDK vs JRE vs JVM

JDK (Java Development Kit) includes tools for developing Java applications. JRE (Java Runtime Environment) allows running Java applications. JVM is the engine that executes bytecode.Example: JDK includes javac compiler,JRE includes the JVM.

Java – Basic Syntax

Java syntax includes the rules for defining variables, functions, classes, and other basic elements of a program.Example: public class Example { public static void main(String[] args) { int x = 5; System.out.println(x); }}

Java – Overview

Java is a high-level, object-oriented programming language used for building web, desktop, and mobile applications.Example: public class MyApp { public static void main(String[] args) { System.out.println("This is a Java program."); }}

Java – Features

Java is platform-independent, object-oriented, multithreaded, and supports automatic memory management (garbage collection).Example: class Example { public void display() { System.out.println("Java Features!"); }}

Handle Java warning popup in selenium webdriver

FirefoxProfile fProfile = new FirefoxProfile(); fProfile.setAcceptUntrustedCertificates( true ); fProfile.setPreference( "security.enable_java", true ); fProfile.setPreference( "plugin.state.java", 2 ); WebDriver driver = new FirefoxDriver( fProfile ); plugin.state.java = 0 never activate, 1 = ask to activate, 2 = always activate

type DefaultHttpClient is deprecated

//Update to HttpClientBuilder (import org.apache.http.impl.client.HttpClientBuilder) import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.HttpClientBuilder; public class Test { public static void main(String[] args) throws Exception { HttpClient client = HttpClientBuilder.create().build(); HttpPost post= new HttpPost(URL); HttpResponse response = client.execute(post); System.out.println(response.getStatusLine().getStatusCode()); } }