Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Posts tagged java
In the current version of OpenJDK's JEP 401: Value Classes and Objects (Preview), it is said that value classes can leak data stored in their fields, and that this is potentially a security concern...
How to verify if a year is leap? Given a numeric value (such as 2023) or some object that represents a date (such as Date, Calendar, LocalDate, etc), how can I do it?
What is wrong in the following code: package oren; import java.util.Scanner; import javax.swing.JOptionPane; public class Main { public static void main(String[] args) { double x,y,z...
Has anyone written a constant-time BigInteger modular multiplication function in Java? I need to use modular multiplication for a cryptographic protocol, and I don't want to try to write it myself ...
I am trying to solve a problem with Vaadin 24.9.10 Spring Boot 3.5.11 application deployed as war file for tomcat 10 on my server. There are a lot of error log messages with varying request paths ...
I try to set an icon (*.png) with javaFX, but it does not show in the task bar, instead I see the default icon (white cogwheel on light gray background). Here is my code: package application; ...
Again, I'm playing around with javaCC, and get those annoying warnings about "unused" and "dead code". Is there a decent way to put a @SuppressWarnings annotation on a whole package but not on the...
When printing a java.time.ZonedDateTime, it's missing the seconds in output, is it a bug or a feature? See my code: package tryNcry; import java.time.Instant; import java.time.ZoneId; import...
This code doesn't compile: package tryNcry; public class ExampleClass<S extends SomeClass> { S[] createArray(int n) { return new S[n]; // obvious compile time ERROR here: ...
Of course, everyone thinks to understand lambdas and generics. I was one of those until recently. Look at my code: package debug; import java.util.function.Function; public class Understand...
I'm developing a Quarkus application that uses Gradle as the build tool. The application doesn't have a main class. I'm trying to configure a launch setup in VS Code, but looks like something is n...
glfwGetTime() and System.nanoTime() both claim to provide precision-based time interval management based on the host platform’s highest resolution and accuracy clock. Naturally, I will only use on...
How do I cast or convert a shadow/shaded class (a package relocated class which is generally generated via tools like gradle/maven) to its original class in Java? The assumption is that both the s...
Although record classes in Java are implicitly final, it's valid to add the final modifier/keyword when declaring a record: final public record Person(String name, String location) {} Does fina...
I'm getting the following exception with deserializing a json file using jackson. Any tips on how to fix it? com.fasterxml.jackson.databind.JsonMappingException: No enum constants for class com.dp...
(Brought over from SE.) The problem I have followed this procedure in order to run Java applications as root when needed from Eclipse (as I use Xubuntu, for instance, when using jnetpcap to cap...
(Brought over from SE) The problem I'm coding a Java Swing application dealing with XML files, so I'm using JAXB in order to marshal classes into documents and unmarshal the other way around. ...
I'm working on a proof of concept for a Spring Cloud Stream application. I want to define my processing logic using classes that implement Function, Consumer, or Supplier. I understand that Spring...
I'm currently working with Apache Camel in a Quarkus application. I would like to configure the application to not discover any routes by default, and only include those defined in specific package...
I'm trying to use the "hexagonal architecture" and "domain-driven design" paradigms together, in a Java application using Spring. I understand that my application should have a structure with 3 la...
Setup I have a database table with field of JSONB type. I access said database using Hibernate. In hibernate I have entity mapped on said table. Entity contains field marked with @JdbcTypeCode(...
While compiling my scala project I'm getting following error. org.scala-lang.modules:scala-parser-combinators_2.13:2.4.0 requires scala version: 2.13.13 org.scalatest:scalatest_2.13:3.2.19 requ...
I have a DTO that contains an enum field: @Getter @Setter static class Foo { Bar bar; } enum Bar { X, Y } When I deserialize a JSON, it allows int as values: var objectMapper ...
I'm currently working on a Java application using Jakarta Persistence with EclipseLink and PostgreSQL. While setting up the application to test the database layer, the persistence configuration is ...
I have a Map with Optional values. I want to filter it to remove empty values. Map<K, Optional<T>> input; Map<K, T> result = input. // here is some code I'm looking for ...
Is it possible to somehow prohibit anonymously subclassing of a specific class? For instance, with a plain public parent class: public class Parent { } Extending this class should not be pos...
I have a simple Spring Boot 3.x reactive application that exposes a RESTful API. The application uses Jdbi in the persistence layer, and the configuration for Jdbi is straightforward: @EnableTrans...
My annotation processor "cannot be found" but everything ~looks okay. In Eclipse IDE, I created a new Maven project with the "quickstart-architype" resulting in a project with this structure: ___...
I am stumped at Maven exec plugin. Running mvn exec:exec -Dexec.executable="curl" (or "echo") works. But when running mvn exec:exec or mvn exec:exec@b (or @a) it fails saying The parameter 'exe...
The javadoc for ServletContext.getContextPath() says that It is possible that a servlet container may match a context by more than one context path. I was trying to find any explanation how t...
Some development tools provide an error message when a user tries to import two things (classes, packages) with the same name. Some programming languages offer a syntax to import one of those thing...
In Eclipse, is it possible to setup custom errors or markers in the editor, for annotation processing? For example, the standard squiggly lines with descriptions. This question is not important. ...
How to log first n lines of a stack trace in Java?
So I googled some on how to make a case insensitive criteria query but could not find the solution very easily. So I basically have code that looks like this: ... query.criteria("fieldName").con...
My question relates to Spring-boot-loader v2.6.15. For the purposes of this question, I will refer to Spring's custom JarFile class as CustomJarFile to avoid confusion. Context I am reusing so...
I need to pass URI's that contain special characters, using Spring Boot. The characters include spaces, curly braces ({ and }), square brackets ([ and ]), and hash signs (#). The problem is that ...
I am currently working with LWJGL and the obstacle I face right now on my project is rendering textures to a cube, e.x a set of 8 vertices with position, color, and UV information. For now, I am st...
I am working with JSF 2.3 and have a selectManyMenu component that is marked as required but that I want to be cleared if the user unselects all items. Currently, the user can unselect all items, b...
One way to remove element from array is to replace element with zero. Below is a rough snippet I am sharing: int N = sc.nextInt(); int pos = sc.nextInt(); int A[] = new int[N]; if(pos == i) { ...
I have an application that works with a JTable, and in this JTable, I want each cell to have both an ImageIcon and some text. I see at this link, JTable supports ImageIcon OR text, but seemingly n...
I have a very simple source file -- HelloWorld.java public class HelloWorld { public static void main(String[] args) { System.out.println("hello world"); } } I have th...
I am migrating an application from Log4j1 to Log4j2 using the API bridge jar. All references to the log4j1.jar have already been removed. I set the system property in Websphere as a JVM argument -...
My large, multi-module Maven project validation (Maven Enforcer plug-in) is playing tricks on me. moduleA> mvn validate correctly finds all modules runs enforcer on all of them displays co...
I am trying to implement DocuSign's eSignature REST API by using Java SDK. I am following instructions here: https://developers.docusign.com/docs/esign-rest-api/sdks/java/setup-and-configuration/ ...
Is it worth using the Java Platform Module System introduced in Java 9 to structure application code? Given that the Java Platform Module System introduced in Java 9 doesn't manage dependency vers...
I have to implement a JSON based REST web service for querying literature. Ordinary users should be able to query data and process it in their clients. The "main user" can adapt database entries vi...
I have float noise values, between -1 and 1, for every x,y coordinate in a 2D area and I am trying to convert that to a whole number between 0 and 319 which represents a vertical z coordinate to re...
I am making a game using JavaFX and the Fxyz library. I have chunks which are made of Point3D's, these points are then passed to a ScatterMesh and that is used to generate a TriangleMesh so I can m...
It's not possible to send data to amazon prime and disney+hotstar. I was trying to send user to amazon prime when they click a (video) link (e.g. https://www.amazon.com/gp/video/detail/B01MSPI8JN/r...
So I am in the process of creating a voxel sandbox survival game (minecraft clone) in javaFX. I am at a point where I need to come up with a way to load the chunks in my surrounding given a render ...
