Powered by Blogger.

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..

Demystifying the Top 10 Spring Annotations for 2024

>> Monday, December 4, 2023

Introduction:

Spring annotations are a powerful tool for autoconfiguring Spring and streamlining the wiring up of components. They serve as metadata that instructs Spring on how to process classes and methods. In this blog post, we'll delve into the top 10 annotations in the Spring framework that every developer should know.




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..

cvc-id.3: A field of identity constraint 'web-app-servlet-name-uniqueness' matched element 'web-app', but this element does not have a simple type.

 The above error will occur in your web.xml while writing Servlet Code or Spring WebMVC code. 

The Error should be

 cvc-id.3: A field of identity constraint 'web-app-servlet-name-uniqueness' matched element 'web-app', but this element does not have a simple type.

Read more..

class path resource [beans.xml] cannot be opened because it does not exist

>> Wednesday, August 25, 2021


 

ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");


Caused by: java.io.FileNotFoundException: class path resource [beans.xml] cannot be opened because it does not exist

at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:187)

at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:333)

... 13 more



Solution:
There are two solutions

1. Take the beans.xml out of package and put in default package.
2. Specify package name of the file..
    ClassPathXmlApplicationContext("com/se/io/beans.xml");

 






Read more..

Solved: Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException

>> Saturday, May 29, 2021

when i run my Simple Spring Boot Application i have faced the below exception in the console. 


as
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606) ~[na:na]
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168) ~[na:na]
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
	... 32 common frames omitted

The JAXB APIs are considered to be Java EE APIs and therefore are no longer contained on the default classpath in Java SE 9. In Java 11, they are completely removed from the JDK. Java 9 introduces the concepts of modules, and by default, the java.se aggregate module is available on the classpath (or rather, module-path). 

As the name implies, the java.se aggregate module does not include the Java EE APIs that have been traditionally bundled with Java 6/7/8. Fortunately, these Java EE APIs that were provided in JDK 6/7/8 are still in the JDK, but they just aren't on the classpath by default. The extra Java EE APIs are provided in the following modules:

Read more..

strip only the numbers from any formatted string of phone number

>> Thursday, April 23, 2020

This is a method which returns a string contains numbers init.The phone numbers may contain in differnt formats Ex: (123) 456-7890
                                 123-456-7890
so we can read these type of characters and returns only the numbers using java method isDigit from Character class.

Read more..

Display first fetter of a word with Capital letter in a given Sentence or String

>> Friday, February 28, 2020

The below code will display every first letter of a word in the sentence will display as a capital letter or in Camel Case using java program.
CamelCase Words in the Sentence

Read more..

convert .pem file to .ppk using puttygen - AWS

>> Friday, January 3, 2020

PEM-Privacy Enhanced Mail is a Base64 encoded DER certificate file format.  PEM certificates are frequently used for web servers as they can easily be translated into readable data using a simple text editor.  Generally when a PEM encoded file is opened in a text editor, it contains very distinct headers and footers.
aws


while creating an instance in Amazon EC2 you will be required to create Key Pairs and .pem file will be generated. I have shown in the below images how to convert .pem file to .ppk file format using puttygen in the below images.

Read more..

Java Program to Print Square Pattern with Stars

>> Wednesday, August 8, 2018

This is a very basic program for beginners who starts learning for loop. This is the best example to understand how the nested loops works. In our program we are going to print the below square star (* ) pattern as shown in the image.
SquarePattern_JavabynataraJ

Read more..

How to run two Tomcat Instances on same machine

>> Thursday, February 15, 2018

Sometimes you are forced to work multiple projects at a time, using two work-spaces using IDE's like MyEclipse or Eclipse or NetBeans. In this situation you should run both the tomcat servers to test your changes at a time from your local. If you run both Tomcat servers at a time from different workspaces you will get the error message as showing below:

"Port 8080 required by Tomcat v8.0 Server at localhost is already in Use."

Tomcat Multiple Instances Error Message_JavabynataraJ

Read more..

Java - Unable to Split a String on Caret (^) symbol as a delimiter

>> Saturday, July 29, 2017

In Java Regular Expressions , Caret ( ^ ) is a Special character. Here it means "it should match the beginning" of an input.
Split method using the Caret symbol on String

Read more..

Java Program to find Perimeter of a Circle

>> Saturday, January 30, 2016

The Mathematical equation to find Perimeter or Circumference of a Circle is C=2Ï€r. We can write hte above equation in our program as 2*Math.PI*r
In this tutorial we will learn how to calculate Perimeter(Circumference) of a Circle using java program. To write this program we are using predefined classes like Math, Scanner or BufferedReader. BufferedReader used to read the value of radius at runtime or from console.
Perimeter Of a Circle

Read more..

Java Program to Calculate Area of a Circle

The Mathematical formula to find Area of a Circle is : A= Ï€r2 or we can write it as given below.
area = pi * radius * radius
So, to find Area of a circle we need the values of 'pi' and radius. In java we have predefined Mathematical value for pi is defined in java.lang.Math.PI = 3.141592653589793. PI is a static final value.
In our program we need to read radius value from the console by using BufferedReader or Console classes.
Calculate Area of a Circle using Java

Read more..

Can I write a Java program without main method ?

>> Thursday, August 13, 2015

Yes, We can write a java program without main method by using static block, only in java version 6. But not possible in later versions like java 7 or 8.
Before going to discuss "How to write a java program without main method", let's get an idea about the programs, which are running without main method.
Java Program without main method_JavabynataraJ

Read more..

Default value of primitive data types in Java

>> Saturday, August 8, 2015

In Real life to store any type of element/material, it should have suitable containers. Lets take water bottle can hold little water, like wise egg tray can hold eggs e.t.c. So to hold any object, there should have their suitable containers. In the same way, any form of the data can be stored by using the primitive data types based on their properties or attributes of the objects.
Default values of primitive data types_javabynataraj

Read more..

Program to find max repeated or duplicate words from a text file

>> Thursday, July 9, 2015

In this tutorial, you will learn How to Find Maximum Occurrence of Words or repeated words from given Text File.
In the earlier post we have gone through How to read a file using BufferedReader and Scanner.This would give you a basic idea to read a file through the Streams. And the related post to this current program best way to find repeated characters from a String also helpful to understand the maximum repeated words from the given text file. Here i am using BufferedReader and FileInputStream to read a file, if the file does not exists this throws an exception FileNotFoundException.
Program to find max repeated words from a text file_javabynataraj

Read more..

Read a file using BufferedReader and Scanner in Java

>> Thursday, July 2, 2015

Being a java developer, will get a chance to work with files using java.util and java.io packages. So mostly we use BufferedReader and Scanner Classes to read different files. These classes will contain respective methods to read files. Here, we will go through the classes and their's differences with a simple java program.
Read a file using BufferedjReader and Scanner_JavabynataraJ

Read more..

Best practice to find Duplicate Character from a String in java

>> Sunday, June 28, 2015

This program could be the best way to find the number of duplicate characters from the given String. Here we are using Map and Set from java.util.Collections package. In the below program we are using Set to collect different characters from the given String. One boolean variable and one method named as findDuplicateChar(String myString) to find the duplicates. Also some known methods like toCharArray() to convert String to character array and for-each loop to iterate Set and Array. Better you can go through the given program to find duplicate characters from the given String.
Find duplicate characters program_JavabynataraJ

Read more..

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