Many Java based programs like Tomcat require JAVA_HOME to be set as environment variable to work correctly. Please note JAVA_HOME should point to a JDK directory not a JRE one. The point of setting the environment variable is to let programs know in which directory executables like javac can be found. Open Advanced System Settings In Windows […]
Catégorie: Java
Java , Java 8 , JDK , JRE, Tutorial, Exemple,Solution, Exception , Error, Eclipes , IDE, Développer, Web Application,
Tutorial creation d’un web service JAX-WS en 5 min
créer un simple projet java >>tpwServer créer la class BanqueService sous le package com.ws et implémentezdeux service { conversion (double mt ) et test() } : changez le comportment de BanqueService d’une classe service a uneclasse webService src→ clique droite → properties →copier location ouvrir le CMD et pointer sur votre projet cd \adresse taper […]
Solution for: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
I wrote a Java Servlet program but when I run it, it was showing the Exception When I give the command in command prompt, it was showing following lines Solution : ave you copied classes12.jar in lib folder of your web application and set the classpath in eclipse. Right-click project in Package explorer Build path […]
Solution for : java.lang.reflect.InvocationTargetException?
What could cause java.lang.reflect.InvocationTargetException ? I have this somewhere in my code: Solution : You’ve added an extra level of abstraction by calling the method with reflection. The reflection layer wraps any exception in an InvocationTargetException, which lets you tell the difference between an exception actually caused by a failure in the reflection call (maybe […]
SOAP VS REST
SOAP stands for Simple Object Access Protocol Il s’agit d’un protocole basé sur XML pour accéder aux services Web. Avantage des services web SOAP : WS SECURITY : SOAP définit sa propre sécurité appelée WS Security. Indépendant du langage et de la plate-forme : les services Web SOAP peuvent être écrits dans n’importe quel langage […]
Autoboxing and Unboxing en java
L’autoboxing est la conversion automatique que le compilateur Java effectue entre les types primitifs et leurs classes d’encapsuleur d’objets correspondantes. Par exemple, convertir un int en un Integer, un double en un Double, etc. Si la conversion se déroule dans l’autre sens, cela s’appelle unboxing. Voici l’exemple le plus simple d’auto-boxe : Character ch = […]
Java : How to Convert Integer to Binary
In Java, we can use Integer.toBinaryString(int) to convert an Integer to a binary string representative. This article will show you two methods to convert an Integer to a binary string representative. JDK Integer.toBinaryString. Old school bit masking technique. 1. Convert Int to Binary Integer.toBinaryString 1.1 This Java example tries to convert an int to a binary string […]
Java : How to Convert Character to ASCII
In Java, we can cast the char to int to get the ASCII value of the char. The explicit cast (int)char is optional, if we assign a char to an integer, Java will auto-cast the char to an int. 1. Convert Char to ASCII This Java example converts a char to an ASCII value, and […]
How to get the index of an element existing in ArrayList ?
indexOf : if you want to get the index of an object existing in Java ArrayList, you can use this method Predefined :
Solution Codingame : Arbre binaire Java – binary tree – Node.java
Solution : Main.java : Filling the binary tree to test…
Java : how to convert negative binary to Integer ?
Review the following Java example to convert a negative integer in binary string back to an integer type. The result is NumberFormatException ! The NumberFormatException is due to overflow, the string 11111111111111111111111111111111 (length of 32) are unable to fit into the 32 bits int type ? Note Note Integer has values from -2^31 to 2^31-1 […]
Comment retourner une chaîne simple en JSON dans Rest Controller ?
Format JSON RestController : Retournez text/plain (comme dans Renvoie uniquement le message de chaîne du contrôleur Spring MVC ) OR enroulez votre chaîne comme un objet. Définissez votre type de réponse sur application/json et vous aurez un JSON qui ressemble à
Solution : How to parse JSON in Java ?
Parse JSON in Java : I have the following JSON text. How can I parse it to get the values of … ? Solution :
Solution getClosestToZero.java : Java Program to Find the Integer number in given array that is closest to zero
It’s one of the most common Java interview questions !!! Let’s talk about this post. In this post, we will see how to write a Java program to find the Integer Number in a given array that is closest to zero. Mentioned below is the snippet from a hiring team. In the question, they stated […]
Exemple Singleton : Comment empêcher de lancer plusieurs fois simultanément une application Java ?
Comment empêcher de lancer plusieurs fois simultanément une application Java ? Par exemple, vous venez de programmer un serveur, vous voulez vous assurer qu’une seule instance est lancée, pour éviter de provoquer des comportements inattendus (une instance reçoit une requête d’un client, et l’autre reçoit son identifiant). En général, quel que soit le programme, il peut […]
“Auto increment” alphabet in Java ?
Auto increment alphabet in Java : There is two solution for auto increment alphabet using java : Solution 1 : Solution 2 : It is also possible with typecasting Read also : Java 7 – Java 8 – loop Map / List – forEach examples Read also : Twitter teste une façon de limiter les […]
Java : multi-line string, text blocks
Java multi-line string text blocks : This article will show you a few ways to declare and use a multi-line string in Java. String + String + String StringBuilder String.format StringWriter String.join (Java 8) Files.lines (Java 8) (“””) Java 13 and Java 14 text blocks (preview feature) Java multi-line string text blocks : Review an […]

Configurez Logback en Java
Afin de normaliser la configuration Logback des applications web sur lesquelles j’interviens, j’ai récemment eu besoin de programmer Logback via son API en Java et non en utilisant la syntaxe XML Joran.Moins courant que le traditionnel logback.xml, cette possibilité de configurer Logback par le code offre davantage de possibilités, ne serait-ce que par son caractère […]
Solution for : Cannot make a static reference to the non-static method
if you have this error that mean you are using your Repository interface in the place of you using and instance of it ,Exemple : if you have an interface PersonnelRepository and you want to use the function getOne(). if you do like that PersonnelRepository.getOne(id) you will have the error Cannot make a static reference […]
Solution for : How to join and split byte arrays, byte[] in JAVA
join and split byte arrays byte[] ? In this example, we will show you how to join and split byte arrays with ByteBuffer and System.arraycopy. ByteBuffer System.arraycopy 1. Join Byte Arrays This Java example uses ByteBuffer or System.arraycopy to join or concatenate two byte arrays. JoinByteArrayExample.java Output Terminal : 2. Split Byte Array In Java, […]