Posts

Showing posts from November, 2017

Online chat for help /Support for website

Image
      For Freshers and professionals copy and paste above code in your website inside head tag, to add online help  support for website.  <!--Start of Zendesk Chat Script--> <script type="text/javascript"> window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s= d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set. _.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute("charset","utf-8"); $.src="https://v2.zopim.com/?5ISpAX1Ty8OLgcJYGpIoa4HjF8FMjT3n";z.t=+new Date;$. type="text/javascript";e.parentNode.insertBefore($,e)})(document,"script"); </script> <!--End of Zendesk Chat Script-->

Gmail Login For website

Image
         For professionals and Freshers                                                          Type following link on your web browser -                                                   https://console.developers.google.com/apis/credentials 2.Create Auth client id by providing required information  URL- http://localhost:8080 REDIRECT URL - http:localhost:8080/gmailtest/success.jsp index.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1"     pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> <script src="https://apis.google.com/js/platform.js" async defer></script> <meta name="google-signin-cli

Hibernate example without any deprecated API's

Create your hibernate application and write following logic in main method and run your code.    Configuration cfg = new Configuration();        cfg.configure();         ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(                 cfg.getProperties()).build();         SessionFactory buildSessionFactory = cfg.buildSessionFactory(serviceRegistry);         Session openSession = buildSessionFactory.openSession();         Transaction beginTransaction = openSession.beginTransaction(); ====================== ============================ create  your bean class object . example -     Employee e=new Employee();     e.setId(103);     e.setAge(1011);     e.setName("rahul");     e.setPhone("2374234"); =============================================================     openSession.save(e);     beginTransaction.commit();

WebService - Swing_Servlet Communication

import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; import java.util.logging.Level; import java.util.logging.Logger; public class SwingServlet {   public static void main(String[] args) throws Exception {  String username="raju";  String password="raju123";             URL url=new URL("http://localhost:8080/ServletDemo/LoginServlet?name="+username+"&&password="+password);     String stringToReverse = URLEncoder.encode("http://localhost:8080/ServletDemo/LoginServlet", "UTF-8");         System.out.println(stringToReverse);         URLConnection connection = url.openConnection();         connection.setDoOutput(true);         OutputStreamWriter out = new OutputStreamWriter(                                          connection.getOutputStream());         out.write("name=" + stringToReverse);         out.close();         BufferedReader in = new Buff

Write Json Data -

public class Address {     String city;     int pin;     public String getCity() {         return city;     }     public void setCity(String city) {         this.city = city;     }     public int getPin() {         return pin;     }     public void setPin(int pin) {         this.pin = pin;     }     public Address() {     }     } ==================== public class Employee {     String name;     int age;     Address address;     public String getName() {         return name;     }     public void setName(String name) {         this.name = name;     }     public int getAge() {         return age;     }     public void setAge(int age) {         this.age = age;     }     public Address getAddress() {         return address;     }     public void setAddress(Address address) {         this.address = address;     }     public Employee() {     }     } ==================== public class WriteJson {     public static void main(String[] args) {         Address a=new Address();        

JSON parsing - Reading Json Data

         Json url-    https://jsonplaceholder.typicode.com/users                       Aim - Want to read Json data from this URL .      Step 1-  Download - java-json.jar         Step 2- Create New Java Project and add this jar to your Project.      Step 3- write code : import java.io.InputStream; import java.net.URL; import javax.net.ssl.HttpsURLConnection; import org.json.JSONArray; import org.json.JSONObject; public class EmployeeJSONParser {     public static void main(String[] args) {         String data="";         try{         URL u=new URL("https://jsonplaceholder.typicode.com/users");             HttpsURLConnection conn = (HttpsURLConnection)u.openConnection();             InputStream in = conn.getInputStream();         int ch;         while((ch=in.read())!=-1){             data=data+(char)ch;         }         }         catch(Exception e){            e.printStackTrace();         }                         try{           

Kotlin - Exception Handling - throw keyword

Example-1 : throw Keyword By Using throw keyword we can handover responsibility of Exception handling to the caller Method Java - class Test{ public static void main(String args[]){ throw new ArithmeticException() } } Kotlin : fun main(args:Array<String>){ throw ArithmeticException() } ================================================ in Kotlin there is Nothing like Checked Exception :  It Means We can throw any number of exception from specific Example : JAVA class Test{ public static void main(String args[]){ throw new ArithmeticException(); throw new ArithmeticException(); } } In this example we will get Compile time error , in java it is not possible to throw more than one exception explicitly  from any method , because there is concepts like Checked Exception. Now Come to Kotlin - In kotlin there is no such a concept : you can throw any number of exception from any block , but yes behavior is same ... after executing exception line , execut

Kotlin - Constructor

Kotlin in Universal Informatics

                           Kotlin For freshers and Developers                   UNIVERSAL INFORMATICS                               INDORE               Kotlin For Android Students (1 .5  hr Batch) 1.   History and Features of Kotlin, Introduction and Setup the environment (netbeans , eclipse,stand alone compiler ) 2.   Variables  and Var vs Val  ,  operators  ,  Decision Making ,  Loop Control 3.   Arrays ,  Classes and Object [Object Oriented Programming] 4.   Inheritance  A bstract class   5.   Interface  ,  Exception Handling 6.   Collection (List,Map,Set)  and String 7.   Multithre a ding                  Android StartUp With Kotlin 8.   Setting  up  Kotlin in Android   First Hello World Program In Kotlin , Converting Java Code to Kotlin Code , Kotlin to Java Communication 9.   Basic UI Controls and event listener examples ,  Multiple Activity App with kotlin  , Activities returning results 10.   Android app with ListView , GridView   wit

Kotlin Compiler - AutoGenrated class

test.kt  - file name fun main(args : Array <String>){ } -> in kotlin we can write a code without class .... yes for us it not compalasry to write a class -> In this example we simply write a code without class ... when we copile this code compiler will genrate class own gnerated class file is : TestKt - after compilation auto generated class =============================================                      How to provide class name to compiler :  In kotlin there is one annotation : @file JvmName("Demo")  @file JvmName("Demo") fun main(args : Array <String>){ } test.kt   In this example after compilation kotlin compiler creates class name as kotlin test.kt kotlin Demo ================================================

Kotlin - Open, final, and abstract modifiers: final by default

As you know- Java allows you to create subclasses of any class, and to override any method, unless it has been explicitly marked with the final keyword. ....... ANALYSIS IS IN PROGRESS......

Kotlin with StandAlone Complier

                     What is standalone compiler :  standalone compiler is a complier that provide  supportive files to compile and    execute your program for only one language. ex : Jdk able to compile and execute only java code not php ,dotnet People who dont like to work or practice on Ides like Netbeans and Eclipse for those "StandAlone" compiler is the best option. Click on following link to download Standalone kotlin compiler  : https://github.com/JetBrains/kotlin/releases/tag/v1.1.51 after downloading compiler unzip it , you get multiple folders in it. 1. Develop your kotlin file 2. compile it 3. execute it Develop Open Notepad (Windows )  / Text Editor (Linux)  / Edie Text ( MAC) : type following program and save with any name with dot "kt" extension   Example test.kt fun main(args:Array<String>){ println("I Love Kotlin"); }  Save this test.kt file in bin folder of kotlin compiler : open ternminal or cmd

Kotlin - Its Not Just Hello World

    fun main(args : Arrays<String>){ println("Its not just a Hello world..!!!"); }   // Yes ... No need to write boiler plate code now..!!!   without class we can write code in kotlin , yes internally  compiler creates class for us.    compiler generated class name - filename with Kt append - filenamKt    kotlinc filename.kt - complie kotlin finlenameKt - Run output -    Its not just a Hello world..!!!   =======================================================     2. If You want to create main method which is static in nature inside  class then try following snippets       class Demo { companion object { @JvmStatic fun main(args: Array<String>) { println ( "Hello Kotlin" ); } } }     Note - class in kotlin is default public and final ================================================================== 3.If you want to create main method or any static method -  there are two