196
questions
0
votes
0
answers
33
views
Maven build working with java8 but not working with more than java11
I had a Maven project which is running on java 8 without any errors .. but the same running on java 11 or more is giving compile time errors
1)Failed to execute goal com.sun.tools.xjc.maven2:maven-...
1
vote
1
answer
1k
views
Generate records from Json schema
For many of my projects I like to use the org.jsonschema2pojo.jsonschema2pojo-maven-plugin maven plugin in order to generate some POJO class from a json schema file. This works great and saves me from ...
3
votes
4
answers
418
views
why java's new feature "Pattern Matching for instanceof operator" doesn't work on List set or Map without typecasting
instanceof doesn't work for List even. for example
package org.practice;
import java.util.List;
public class InstanceOfDemo {
public static void main(String[] args) {
Employee emp1 = ...
0
votes
0
answers
41
views
How to update Java Android JDK path in Windows
I updated my flutter SDK recently and started having issues with my Android studio. Initially I was using Java 8 but I upgraded my Java jdk to Java 14. I have set my Environment variable to point to ...
1
vote
1
answer
886
views
does serialVersionUID make sense in a java record?
Does it make sense to add a serialVersionUID field to a record? I think a record might be meant to be serializable, so implementing Serializable and adding a serialVersionUID might be unnecessary, but ...
0
votes
0
answers
75
views
How to update Gradle version to 7.3 in a Java project downloaded from GitHub with JDK 17 and avoid dependency issues?
I downloaded the project from the git hub to java, he has a gradle build version 6.3, and it needs to be run with the sdk version 14, but for my assignment at the university I need to run the project ...
0
votes
1
answer
435
views
How to create docker image with java 14 and maven and jboss
FROM maven:3.6.3-jdk-14 as BUILD
COPY . /usr/src/myapp/src
RUN mvn -f /usr/src/myapp/src/pom.xml clean install
FROM jboss/wildfly:14.0.1.Final
# Set the WILDFLY_VERSION env variable
ENV m_VERSION ...
3
votes
1
answer
132
views
Java's "&&" vs "&" operator
I am using the example from Java the complete reference by Herbert Schildt, 12th ed and Java is 14
Where he gives the 2 following examples (if blocks), the first one is ok and the 2nd one is wrong ...
0
votes
1
answer
200
views
Are Java Records suitable to represent the nodes of a graph?
One of the classic ways to represent a graph (as in Graph Theory) is:
class Node {
String value;
List<Node> children;
// constructor, equals, etc. are omitted
}
The question is with ...
4
votes
1
answer
2k
views
Why can't return be expressed in one line when using a Switch Expression?
while (true) {
console.mainMenu();
String inputCommand = console.input();
switch(inputCommand) {
case "exit" -> return;
case "create" -> {
...
5
votes
1
answer
2k
views
Java 14 Switch-Expression with default case
How can I declare a switch case as default, with the new Java 14 Switch Expressions?
All I want is:
enum States {
PLAY, STOP
}
...
States state = ...
switch (state) {
case PLAY -> { run(); ...
2
votes
1
answer
624
views
What is the worst case time complexity of Java 14+ Arrays.sort( int[] )?
While I know this seems obvious I'll explain my confusion. I've always thought of Quicksort's worst case time complexity as O(n^2). The documentation for Arrays.sort(int[]) from Java 7 to Java 13 says:...
0
votes
2
answers
286
views
How to get the MethodInfo of a Java 14 method reference?
I'm essentially asking the same as this old question, but for Java 14 instead of Java 8. To spare answerers the trouble of navigating to the old question, I'll rephrase it here.
I want to get the name ...
-1
votes
1
answer
710
views
How can I correctly use the stream map() in this use case involving the conversion of an entity class instance into a DTO instance?
I am working on a Spring Boot application and I am trying to use a more modern (Java 8+ constructs) but I am finding some difficulties trying to implement the following changes to my existing code.
I ...
1
vote
1
answer
2k
views
How is the scope of pattern variables resolved in java?
I was going through the pattern variables in java. While reading the JLS it mentioned several conditions regarding when a pattern variable is introduced.
It mentions -
The analysis relies on the ...
1
vote
3
answers
802
views
Javax-Persistance : Entity does not have a primary key using Java records
I am trying to create a entity class using Java record, but I get the error message
"Entity does not have primary key" although I assigned an ID annotation.
import javax.persistence.*;
...
1
vote
1
answer
385
views
DateTimeFormatterBuilder appendOptional multiple ISO standards results in DateTimeParseException
public class Main {
public static void main(String[] args) {
DateTimeFormatterBuilder dtf = new DateTimeFormatterBuilder()
.appendOptional(DateTimeFormatter....
2
votes
0
answers
42
views
Using Java14 to manually compile the module, but an error is reported
I wrote a very simple Example of a Java module following the tutorial, but when using the javac command, I didn't get an error, and when compiling with the Java command, I got an error:
Error occurred ...
-1
votes
1
answer
880
views
Base64 Decoding issue with Arabic content in java
I have a spring boot application (2.2.6.RELEASE). In my application I need to decode a base64 string into a xml data. This xml data contains Arabic contents. I am using "apache common" (...
4
votes
1
answer
1k
views
javafx 16 WebEngine Exception "SSL Handshake failed"
I am porting an android app to javaFX for windows deployment, i'm new to javaFX and desktop deployment, but not so new to java.
The app contains a WebView that loads a url obtained from a server via ...
3
votes
1
answer
2k
views
Can JavaFX realistically be used in a non-modular environment?
I've attempted to use JavaFX by following instructions found at:
https://openjfx.io/openjfx-docs/ under "JavaFX and IntelliJ" -> "Non-modular with Maven"
After completing steps ...
17
votes
2
answers
4k
views
Java records and field comments
When we use classes in Java it's very simple to add JavaDoc/comment for each class field/method:
class Product {
//Product unique identifier
private int id;
}
If we migrate these classes to ...
1
vote
0
answers
1k
views
How to read/send USB data in just plain Java?
Before answering, please read all of this so you don't miss any details.
I have been looking on the internet for days, and trying to look through the javadocs, but I cannot find the answer anywhere.
...
2
votes
0
answers
1k
views
How to override Java's jpackage wix defaults to create an environment variable containing the installation location?
I have a desktop Java application that is packaged using jpackage (Java 14).
Windows Installer
I would like to know how to modify/override the jpackage wix defaults such that the installation location ...
0
votes
1
answer
193
views
Java 14 javax.net.ssl.SSLException occurs only on some computers with identical cacerts files
I have a Java 14 application where some computers throw a javax.net.ssl.SSLHandshakeException or javax.net.ssl.SSLException when trying to access https://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_1p00....
4
votes
3
answers
6k
views
Convert one Optional<List<Object>> to another Optional<List<Object>> in Java
How can I convert Optional List object from one type to another, for an example
Optional<List<ProductMultipleOptionViewModel>> productOptionType1 // One type
Optional<List<...
2
votes
1
answer
490
views
How to release a mutex lock held by Thread which never lets it go, by continuously listening to a socket
There are two classes Client and ChatWindow, client has DatagramSocket, InetAddress and port fields along with methods for sending, receiving, and closing the socket. To close a socket I use an ...
0
votes
1
answer
635
views
How to connect to oracle using jdbc
I am trying to connect to Oracle from jsp using jdbc. but the class.forName(...) throws exception
the full code is here:
%@ page language="java" contentType="text/html; charset=ISO-8859-...
0
votes
0
answers
382
views
Error while connect to SQL Server with jdbc Logstash
I have SQL Server in my PC that I login with SSMS with server name = DESKTOP-XXXX\MSSQLSERVER01 and windows auth.
What I tried to to is put the data from rabbit mq to SQL Server with Logstash. But I ...
2
votes
3
answers
8k
views
Java error: release version 14 not supported in IntelliJ IDEA
I'm using IntelliJ to run a Java program, but I keep on getting this error "java: error: release version 14 not supported"
9
votes
1
answer
1k
views
Do Java records support "with" syntax?
Java 14 brings records, which are a great addition seen in many functional languages:
Java:
public record Vehicle(String brand, String licensePlate) {}
ML:
type Vehicle =
{
Brand : string
...
0
votes
0
answers
234
views
Apache NetBeans IDE 12.0 "Activation Failed"
Try to create a new project (Java with Ant -> Java Application)
However, I get the following errors:
I've tried many ways and also uninstall and reinstall the jdk14 and Apache Netbeans 12.0 plenty ...
3
votes
2
answers
2k
views
java.lang.IllegalAccessError when using vertx web client version 4.0.0
Using vertx 4.0.0 with jdk 14. I'm getting the following exception when trying to make a REST request using the vertx web client:
15:56:48.294 [vert.x-eventloop-thread-0] ERROR io.vertx.core.impl....
40
votes
3
answers
5k
views
How is NullPointerException in Java 14 different from its predecessor?
One of the important features that were introduced with Java SE 14 was the Helpful NullPointerExceptions which is related to the usability of the NullPointerException. What makes NullPointerException ...
43
votes
4
answers
24k
views
What are switch expressions and how are they different from switch statements?
As part of Java SE 12, switch expressions were introduced and since Java SE 14, they have been standardized. How are they different from switch statements?
1
vote
1
answer
3k
views
Cannot resolve class 'HibernatePersistenceProvider'
I have the hibernate dependency in build.gradle but I'm getting the following error
> Task :JPABootstrapping.main() FAILED
Exception in thread "main" javax.persistence....
6
votes
2
answers
3k
views
Java records and the single class per file limit
I'm trying out the new records feature with java 14, currently in preview.
I know that in Java one has to have exactly one public class per file but with the new record syntax being so nice and short ...
3
votes
0
answers
2k
views
Gradle does not detect compatible JDKs of multi-release jar
I created a multi-release jar library using Gradle 6.7 being on JDK 14 which is geared to be compatible with JDK 11 and 14. Therefore I use the following build.gradle which puts all classes in a ...
0
votes
1
answer
626
views
Error: Repeatedly getting error 'Java 14 not supported
Trying to learn Spring-Boot, and improving my Java skills. I keep getting error stating that '..java: error: release version 14 not supported..'. My jdk is set for jdk-11 on preferences page. I ...
0
votes
0
answers
321
views
JavaFX cannot load image from resource folder
I have been working on a JavaFX project with Maven. I am using JDK 14 with IntelliJ IDE to compile my project into a JAR artifact.
I have linked the CSS files into FXML through Scene Builder. The CSS ...
-1
votes
1
answer
783
views
Playing Media/AudioClip in JavaFX with Java14 [duplicate]
I am trying to play a sound in a JavaFX application but am failing to do so because of this error:
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect....
4
votes
2
answers
56k
views
How to fix Java UnsupportedClassVersionError [duplicate]
I've run into this error a few times trying to brush up on my Java. Looked up solutions on the internet and most suggestions were to compile or run the file with a flag/option argument to specify the ...
1
vote
0
answers
1k
views
Why does JDK 15's time API have increased precision on Linux, but not on macOS? [duplicate]
java.time.OffsetDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME) on OpenJDK 15 (build 36) on Linux has a 9 digit precision after the second:
2020-10-20T13:23:03.079208368+02:00
But the same ...
2
votes
1
answer
539
views
opencsv throws exception when called from main, and module-info.java is present
I want to use opencsv in a project that is build with Java 14, using Java module system. So it has a module-info.java file.
A call to a method in opencsv works fine when it's initiated from a unit ...
16
votes
1
answer
23k
views
Java records validation anotation
I have old POJO with valid annotation:
public class SomeData {
@NotNull(message = "Data not be null")
private String data;
public FormData(String data) {
this.data = ...
0
votes
2
answers
505
views
Why can't IntHolder be found in JDK 14?
When I type IntHolder, it prompts me to Cannot resolve symbol IntHolder.My JDK is 14.And I can't find it in the JDK documentation.Will some classes or others disappear with the JDK version update?
-1
votes
1
answer
1k
views
Can't use 'java' command in IntelliJ terminal when trying to run my main in it
I'm trying to run my java program using the java and javac command, but it returns this in the terminal:
'java' is not recognized as an internal or external command,
operable program or batch file.
I'...
8
votes
1
answer
3k
views
JDEPS Module Not Found Exception when listing dependancies
I have been working with JLink to create minimal JRE for various Spring Boot applications. I have successfully done this manually by figuring out the required Modules via trial and error. After ...
0
votes
0
answers
247
views
A JNI error has occured when running exe file
So I just converted a jar file into an exe file.
My Jar file seems to run smoothly and the code is executed as intended
However when I run my .exe file I get an error window saying "A JNI error ...
1
vote
1
answer
433
views
Jenkins and Java 14, how to properly select the JDK compiler for a given job?
I've found few topics related to this, but nothing new in terms of Java 14 and recent Jenkins versions. What are the recommended steps to make Java 14 available in Jenkins as an option to compile Java ...