Powered by Blogger.
Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

new features in java 23

>> Wednesday, December 4, 2024

As of the latest Java version (Java 23), key new features include previews for module import declarations, stream gatherers, scoped values, and a revised class-file API. Additionally, certain memory access methods within "sun.misc.Unsafe" have been deprecated. 
Highlights of Java 23 features:
Module import declarations (preview):
Allows importing all public APIs of a module with a single line, simplifying module usage. 
Stream gatherers (preview):
Provides a new "gather" intermediate operation for more flexible stream transformations. 
Scoped values (preview):
Enables sharing of immutable data across threads for better concurrency management. 
Class-file API updates:
Changes to the class file format, including potential modifications to how bytecode is represented. 
Deprecation of "sun.misc.Unsafe" methods:
Certain memory access methods within the "Unsafe" class are marked as deprecated, encouraging developers to use safer alternatives. 
https://www.infoworld.com/article/2338097/jdk-21-the-new-features-in-java-21.html 

Read more..

java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

>> Friday, October 22, 2021

INFO: Marking servlet [dad-frontController] as unavailable
Oct 22, 2021 6:31:27 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet [dad-frontController] in web application [/home.com] threw load() exception
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

Servlet /webapp threw load() exception or
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet



follow the below steps when you face the above error while running the spring web or spring MVC application on your machine.

Read more..

SEVERE: Servlet [Controller] in web application [/myfirst-mvc-project] threw load() exception

>> Thursday, September 30, 2021

I have got the below error while running my First Spring Web MVC application using Tomcat Server.

The error log in the Console is: 


 INFO: Marking servlet [dad-frontController] as unavailable

Sep 30, 2021 10:34:12 PM org.apache.catalina.core.StandardContext loadOnStartup

SEVERE: Servlet [dad-frontController] in web application [/myfirst-mvc-project] threw load() exception

java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet


Read more..

Web Services notes by Mr Sekhar from Naresh i Tecnologies

>> Wednesday, September 24, 2014

Web Services class notes by Sekhar sir from Naresh i Technologes. Sekhar sir's full name is SomaSekharReddy. He is a one of the best trainers in the Hyderabad ameerpet institutes. Also he had trained many students on XML technologies, and taken classes on all the modules of Spring and given good notes on Spring modules. Most of the topics covered on AOP &MVC, IOC and DAO, ORM modules. Present in the Web Services he covered messages exchanging patterns,Web Service Definition Language(WSDL),Java API for XML-Based Rmote Procedure Calls (JAX-RPC),Java API for RESTful Web Services(JAX-RS) and Apache AXIS.
Web Services notes by Sekhar sir_JavabynataraJ

Read more..

Maven The Definitive Guide pdf Download

>> Wednesday, April 23, 2014

What is Maven? Maven is a “build tool”, used to build deployable artifacts from source code.I think you may got an idea about Ant. Ant also a build tool then What is the difference?
Maven The Definitive Guide Download_JavabynataraJ
The difference is ..A build tool such as Ant is focused solely on preprocessing, compilation, packaging, testing, and distribution. A project management tool such as Maven provides a superset of features found in a build tool. In addition to providing build capabilities, Maven can also run reports, generate a web site, and facilitate communication among members of a working team.

Read more..

How to configure Java in MyEclipse 9.1

>> Wednesday, August 29, 2012

Configure java1.5 on MyEclipse_JavabynataraJ
To run java using MyEclipse 9.1 we should configure this. MyEclipse having more features to develop projects and this will be very useful for developers. This is the next generation of the MyEclipse Enterprise Workbench IDE for enterprise Java and web developers. Basically it supports Java EE 6.0 features such as:
  • Servlet 3.0
  • JSF 2.0
  • JPA 2.0
  • EJB 3.1
  • JAX-RS 1.1
MyEclipse having some Struts 2 Enhancements
  • Improved connection routing
  • Better undo/redo suport
  • Struts 2 specific validation for Struts 2 configuration files
Install MyEclipse in you System.

Read more..

How to Copy properties from one Bean OtherBean

>> Saturday, August 4, 2012

As we know the Bean class containing the variables with setters and getters methods. We can access through the getXxx and setXxx methods by different properties. To copy the properties form one bean to another they should have same datatypes.

To Run our program the requirements are:

As per shown in the below image you can create the files in Eclipse.

Read more..

Java The Complete Reference 7th Edition Download

>> Monday, January 30, 2012


The world's leading programming author offers comprehensive coverage of the new Java release

The definitive guide to Java has been fully expanded to cover every aspect of Java SE 6, the latest version of the worldAnd#39;s most popular Web programming language. This comprehensive resource contains everything you need to develop, compile, debug, and run Java applications and applets.

The Definitive Guide for Java Programmers

In this comprehensive resource, top-selling programming author Herbert Schildt shows you everything you need to develop, compile, debug, and run Java programs. This expert guide has been updated for Java Platform Standard Edition 6 (Java SE 6) and offers complete coverage of the Java language, its syntax, keywords, and fundamental programming principles.

Read more..

Download Java 2 Core Language Little Black Book

>> Sunday, January 29, 2012

The focus of this book is on the core Java language as implemented by the new version of Java, version 1.4. The book features a logical, sequential approach with concise overviews, then step-by-step immediate solutions created by a master Java programmer. This book is also packed with over 150 code listings which can be used as is or quickly modified.


  • Paperback: 440 pages
  • Publisher: Paraglyph Press; 1 edition (August 2002)
  • Language: English


Read more..

Singleton Design Pattern Example Program

>> Tuesday, April 19, 2011

Singleton Design pattern will allow only one object per Class(JVM).
Before Writing Singleton Design pattern you should follow these steps.

#1). create an instance as static and return type as The same class, and it should be assigned as null.

private static Singletonn instance = null;

#2). "Create a Constructor as private" to deny the creation of object from other class.

private Singletonn(){
        
    }

#3). Write a static method to create object for our class.It should be Once for a class.

public static Singletonn getInstance(){

}

#4). At last return the class Object.

Here We are creating the object once only not again and again.The first time created object is returning again when you called.

package javabynataraj.basic;

class Singletonn {
    private static Singletonn instance = null;
    private Singletonn(){
        
    }
    public static Singletonn getInstance(){
        if(instance==null){
            instance = new Singletonn();
        }
        return instance;
    }
}

public class Singleton{
    public static void main(String[] args) {
        System.out.println("before calling ...");
        System.out.println(Singletonn.getInstance());
        System.out.println("Once Called");
        System.out.println(Singletonn.getInstance());
        System.out.println("Second time called");
    }
}
Reference books:

  • Design Patterns : Elements of Reusable Object 

  • DESIGN PATTERNS IN JAVA 2nd  Edition 

  • Data Structures And Algorithms With Object-oriented Design Patterns In Java 1st Edition 

  • Dependency Injection: Design Patterns Using Spring and Guice
  • Read more..

    What is Deserialization in java ? Write a simple program using Deserialization?

    >> Monday, April 18, 2011

    Deserialization is a process of converting the data from files or database converting to Stream of bytes using class Objects.


    The Deserialization can be done after serializing the data only.Then we can read the data from the serialized files.

    Convert your Serialized file into file form.

    File fromFile = new File("Emp.ser");

    By using the below two classes we can do the process of deserialization.
    #1. FileInputStream
    #2. ObjectInputStream
    A FileInputStream obtains input bytes from a file in a file system. What files are available depends on the host environment.
    FileInputStream fis = new FileInputStream(fromFile);

    An ObjectInputStream deserializes primitive data and objects previously written using an ObjectOutputStream. This can be Converts the Serialized file into the Object form.
    ObjectInputStream ois = new ObjectInputStream(fis);

    To get the object of a serialized file we have to typecast into our class Employee to read the values in a file using variable names.
    Employee emp = (Employee) ois.readObject();

    After that close all the object connections.
    You should write the  Employee class already written in Serialization.(check it there) 
    Program for Deserialization:
    package javabynataraj.iopack;
    
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.ObjectInputStream;
    
    public class Deserial {
        public static void main(String arg[]) {
            File fromFile = new File("Emp.ser");
            try {
                FileInputStream fis = new FileInputStream(fromFile);
                ObjectInputStream ois = new ObjectInputStream(fis);
                Employee emp = (Employee) ois.readObject();
                System.out.println("Deserialized data: \n"+ emp.eno + " "+ emp.ename +" "+ emp.esal+" "+emp.eaddr+ "  from Emp.ser");
                ois.close();
            } catch(IOException e) {
                System.out.println("Deserialization failed");
                System.out.println(e);
                System.exit(1);
            } catch(ClassNotFoundException e) {
                System.out.println("Deserialization failed");
                System.out.println(e);
                System.exit(1);
            }
        }
    }
    

    Read more..

    JSP Implicit Objects

    >> Wednesday, March 23, 2011

    Actually Servlet don't have these implicit Objects After introducing of JSP it contains by default and with readymade Objects to use in our web applications.

    These are available for programmer through Container. The implicit objects are parsed by the container and inserted into the generated servlet code. They are available only within the jspService method and not in any declaration. Implicit objects are used for different purposes. Our own methods (user defined methods) can't access them as they are local to the service method and are created at the conversion time of a jsp into a servlet.


    These are 9 implicit Objects 

    request
    response
    page
    pageContext
    application
    exception
    out  
    config
    session

    Read more..

    What are the JSP page attributes

    >> Tuesday, March 22, 2011

    Syntax of the declaration of the page directive with it's attributes is <%@ page attributeName="values" %>. The space between the tag <%@ and %> before the page(directive name) and after values of the last attribute, is optional, you can leave the space or not.


    Following are name of the attributes of the page directive used in JSP:

    JSP Page Directive Attributes


    • language
    • extends
    • import
    • session
    • buffer
    • autoflush
    • info
    • errorPage
    • isErrorPage
    • isThreadSafe

    Read more..

    What is the difference between doGet() and doPost() methods ?

    >> Monday, March 21, 2011

    The difference has given below......


     
    doGet

    doPost
    In doGet Method the parameters are appended to the URL and sent along with header information
    In doPost parameters are sent in separate line in the body
    Maximum size of data that can be sent using doget is 240 bytes
    There is no maximum size for data
    Parameters are not encrypted
    Parameters are encrypted
    DoGet method generally is used to query or to get some information from the server
    DoPost is slower compared to doGet since doPost does not write the content length
    DoGet should be idempotent. i.e. doget should be able to be repeated safely many times
    This method does not need to be idempotent. Operations requested through POST can have side effects for which the user can be held accountable for example updating stored data or buying items online.
    DoGet should be safe without any side effects for which user is held responsible.
    This method does not need to be either safe.





    Read more..

    Disadvantages of Hibernate

    >> Sunday, March 20, 2011

    The main disadvantages of Hibernate is given in detail.

    1) Steep learning curve.

    2) Use of Hibernate is an overhead for the applications which are :

    simple and use one database that never change
    need to put data to database tables, no further SQL queries
    there are no objects which are mapped to two different tables
    Hibernate increases extra layers and complexity. So for these types of applications JDBC is the best choice.

    3) Support for Hibernate on Internet is not sufficient.

    Read more..

    JDBC Vs Hibernate

    >> Saturday, March 19, 2011


    Why is Hibernate better than JDBC

    1)   Relational Persistence for JAVA

    Working with both Object-Oriented software and Relational Database is complicated task with JDBC because there is mismatch between how data is represented in objects versus relational database. So with JDBC, developer has to write code to map an object model's data representation to a relational data model and its corresponding database schema. Hibernate is flexible and powerful ORM solution to map Java classes to database tables. Hibernate itself takes care of this mapping using XML files so developer does not need to write code for this.

    2)   Transparent Persistence

    The automatic mapping of Java objects with database tables and vice versa is called Transparent Persistence. Hibernate provides transparent persistence and developer does not need to write code explicitly to map database tables tuples to application objects during interaction with RDBMS. With JDBC this conversion is to be taken care of by the developer manually with lines of code.

    Read more..

    Hibernate communication with RDBMS

    General steps:

    1. Load the Hibernate configuration file and create configuration object. It will automatically load all hbm           mapping files.
    2. Create session factory from configuration object
    3. Get one session from this session factory.
    4. Create HQL query.
    5. Execute query to get list containing Java objects.

    Example: Retrieve list of employees from Employee table using Hibernate. /* Load the hibernate configuration file */

    Configuration cfg = new Configuration(); cfg.configure(CONFIG_FILE_LOCATION);

    /* Create the session factory */

    SessionFactory sessionFactory = cfg.buildSessionFactory();

    /* Retrieve the session */

    Session session = sessionFactory.openSession();

    /* create query */

    Query query = session.createQuery("from  EmployeeBean”);

    /* execute query and get result in form of Java objects */ List finalList = query.list();

    EmployeeBean.hbm.xml File


    "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">




















    Read more..

    4. Introduction to Hibernate

    Hibernate is an Object-Relational Mapping (ORM) solution for JAVA. It is a powerful, high performance object/relational persistence and query service. It allows us to develop persistent classes following object-oriented idiom – including association, inheritance and polymorphism.

     Hibernate Architecture

    Hibernate:

    1) itself opens connection to database,
    2) converts HQL (Hibernate Query Language) statements to database specific statement,
    3) receives result set,
    4) then performs mapping of these database specific data to Java objects which are directly used by Java application.

    Hibernate uses the database specification from Hibernate Properties file. Automatic mapping is performed on the basis of the properties defined in hbm XML file defined for particular Java object.


    Read more..

    3.Interaction with RDBMS

    These are the General steps to follow  while usingn JDBC.

    1) Load the RDBMS specific JDBC driver because this driver actually communicates with the database.
    2) Open the connection to database which is then used to send SQL statements and get results back.
    3) Create JDBC Statement object. This object contains SQL query.
    4) Execute statement which returns resultset(s). ResultSet contains the tuples of database table as a result of SQL query.
    5) Process the result set.
    6) Close the connection.

    Example: Retrieve list of employees from Employee table using JDBC.

    String url = “jdbc:odbc:” + dbName;
    
    List employeeList = new ArrayList();
    
    //load the jdbc-odbc driver 
    
    class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
    
    //Open a connection to database
    
    Connection con = DriverManager.getConnection(url);
    
    //create Statement object
    
    Statement stmt = con.createStatement();
    
    //execute statement
    ResultSet rs = stmt.executeQuery("SELECT * FROM Sells"); while ( rs.next() ){
      EmployeeBean eb = new Employeebean(); 
      eb.setName(rs.getString("name")); 
      eb.setSalary(rs.getFloat("salary")); 
      employeeList.add(eb);
    }
    
    Reference Books:

    Read more..

    1. Introduction to JDBC

    The Brief introduction about JDBC .

    1. Introduction to JDBC
    2. JDBC Architecture
    4. Introduction to Hibernate 
    5. Hibernate Architecture 
    6. Hibernate Communication with RDBMS 
    7. Hibernate vs. JDBC 
    7.1. Advantage of Hibernate over JDBC 
    7.2. Disadvantages of Hibernate

    Read more..

    Related Posts Plugin for WordPress, Blogger...
    © javabynataraj.blogspot.com from 2009 - 2022. All rights reserved.