Questions tagged [java]
Java is a high-level object-oriented programming language. Use this tag when you're having problems using or understanding the language itself. This tag is frequently used alongside other tags for libraries and/or frameworks used by Java developers.
1,916,944
questions
0
votes
0
answers
5
views
JPA/Hibernate JpaSystemException: identifier of an instance of X was altered from Y to Z
I'm updating my Spring Boot application from Java 11 to Java 17, and Spring Boot 2.7.18 to 3.2.4, and running the tests I'm getting an error.
So, I have a entity called WorkloadDAO like this:
@Entity
@...
0
votes
0
answers
11
views
Avoiding double lookup in Map
I have a performance-critical tight loop which, for a large number of keys, needs to look up the key in a map and do something with that key if it exists in the map:
Map<Integer, SomeClass> map =...
0
votes
0
answers
6
views
When i reload or logout from my app the disconnect function in the backend runs twice and i am getting two session different ids when logging out
Hi i am developping an application where there is a chat feature and facing a problem that when i logout from the app i am having two disconnects from two different session ids for the same user
The ...
-1
votes
0
answers
9
views
project using RFID and module ESP-01 connect in android studio [closed]
je veut crée une application en Android studio qui jouent le rôle de recevoir tout les mouvement dans le partie électronique (RFID ,ARDUINO, ESP-01,buzer,led, lcd_I2C,et servomoteur) quand il y a une ...
0
votes
0
answers
38
views
How does outlook disable screenshot [closed]
Outlook has an email encryption function. Emails with this feature turned on will not be able to be screenshotted. When the recipient takes a screenshot of this email, the screenshot result is a black ...
0
votes
0
answers
14
views
While using Lombok 1.18.32 with java 17 it gives error that The type Lombok.Setter and Lombok.Setter is not accessible
screen shot errorenter image description here
Lombok version 1.18.32 is compatible with Java 8, but encounter errors when attempting to use it with Java 17, despite having installed it in Eclipse.
...
0
votes
0
answers
6
views
"No map fields found in com.google.cloud.compute.v1.Instance" error when getting instances in Google Cloud API Java
I am trying to get the instances information with Google Cloud API in Java.
When I send the list request I get an exception.
Can you tell me why I getting this exception?
I do not know about the ...
0
votes
1
answer
11
views
Not able to identify the checkbox element ::before and ::after in Selenium
I want to click on the checkbox. Tried different methods. But not working. Any solution?
@FindBy(xpath="//label[@for='Tnc']")
Still its not getting the exact element of check box. Instead it ...
0
votes
1
answer
23
views
how to avoid while loop while waiting for future complete?
I have a problem with a java future and an handler function. code example:
public HealthCheckResponse call() {
String redisHost = this.configuration.getRedisHost();
log.info("connect to ...
0
votes
0
answers
7
views
Starting first job causes - Dispatcher has no subscribers for channel exception when declared multiple DirectChannels
I have a Spring Batch application which is successfully running spring batch jobs but i have exception when declaring multiple DirectChannels.
The exception happens when i start the "firstJob&...
-1
votes
0
answers
9
views
Using SpringSecurity only for the entire authentication/authorization
I am going to develop an incident reporting application in java and angular. I am planning to use SpringSecurity for the whole authentication/authorization process, I don't know if it's a good idea or ...
0
votes
0
answers
12
views
Eclipse: Can't see .xml files in a specific directory [closed]
I'm working on a Java web application using Eclipse and I'm trying to see the log .xml files in a specific directory on my Windows. However, after clicking the save button in my application, the .xml ...
0
votes
0
answers
8
views
Fabricmc cannot cast minecraft class to injected interface
I have interface PackItemStack and ItemStackMixin that implement it. Mixin is registered in mixin.json config.
But when I try to cast main class ItemStack to interface, IDE gives an error ...
0
votes
0
answers
15
views
Process 'command 'C:\Program Files\Java\jdk-17\bin\java.exe'' finished with non-zero exit value 1
i am getting below error while trying to start my java application. i configured java 17 in intellij and in environment variable. So just wanted to know, what is the possible reason of this error.
...
0
votes
1
answer
22
views
Java Pojos - Setter-Call (Field Touched) Detection
Pojos are often used as Models/DTOs for inserting/updating data into a database.
They need to by validated (with a Validator) to make sure they only contain the expected fields for the use-case:
...
0
votes
0
answers
7
views
Jacoco Coverage in Multi-Module Gradle Project Not Including Submodules
I am developing a multi-module Gradle (8.7) project, structured such that one module acts as the main application, while the others are libraries used by this application. All unit tests are located ...
0
votes
0
answers
12
views
Selenium java error :: unknown error: unhandled inspector error: {"code":-32000,"message":"Not attached to an active page"}
This is my code
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\xyz");
ChromeOptions options = new ChromeOptions();
options....
-2
votes
0
answers
13
views
Converting ISO 8601-compliant String to epoch on KitKat
I have the following ISO8601-compliant string:
2024-03-25T11:34:15.000Z
I need to convert it to java Date. I found the following solution:
Date date = Date.from(Instant.parse("2024-03-25T11:34:...
0
votes
0
answers
19
views
SQL Error: -302, SQLState: 22001 while using String function with a dynamic parameter in db2/hibernate
Trying to run a query, in java. Will provide the part where I am facing issue with
select j.* .......... where lower(jp.value) = lower (:mailTo)...
query.setString("mailTo", mailTo);
List<...
-1
votes
0
answers
19
views
Java. How to check what objects are created and where? [closed]
If I have a working program written in Java, is there a way to check (during working that program) in what order objects are created and in which methods?
0
votes
0
answers
22
views
Even though I added my SSL certificate, I get the "not secure" error
I programmed a rest API, purchased an SSL certificate with Java Spring Boot, and configured the SSL certificate into my project. I successfully started the project with https, but when I run it from ...
0
votes
0
answers
14
views
Open telemetry integration in java
I used the below command and resource for the setup of the Opentelemetry in java.
java -javaagent:path/to/opentelemetry-javaagent.jar -Dotel.resource.attributes=service.name=your-service-name -Dotel....
-1
votes
0
answers
7
views
Create new Opentelemetry Trace in java
We have traces that have hundreds/thousands of spans because of loops and that seems pretty blooded.
Is there a way to create custom Opentelemetry traces in java ? Let's say in a loop, I want to ...
0
votes
0
answers
11
views
How to solve sonarqube issue based on bug to return a copy
how to solve this issue return a copy of "deductionfrequency". code mentioned below getter method
type : Vulnerability
tags : cert,cwe,unpredictable
issue : Return a copy of "...
0
votes
0
answers
12
views
If I expand the Hazelcast repository with a method, what disadvantages do I have in comparison to expanding the service?
Hazelcast and the Application are both running in Kubernetes. I was wondering if there are any disadvantages of expand the Hazelcast repository with a method.
In general and also regarding the JDK, ...
0
votes
0
answers
13
views
Can't decompile APK file properly
I have an APK file without its source code. I used a lot of tools to decompile it, like jadx and jd-gui, and they constantly throw decompilation errors. I know that the decompilation process is rather ...
0
votes
0
answers
10
views
RedisConnectionFailureException intermittently
We observed RedisConnectionFailureException intermittently as mentioned in above stacktrace, quantum is around 2-3 per 15 mins, which is very low, but still it should not come ideally. As you can see ...
-1
votes
0
answers
16
views
Is it possible to work with remote repo without creating wprking directory in local fs using JGit?
I would like to push some files in bare repo (such as empty repo in Github).
If i clone this repo i will have working directory localy, but i don't want it, because it could be 1000 of such repos in ...
0
votes
0
answers
8
views
RPA using robotframework in springboot
I have worked on java spring-boot but I don't have much knowledge about python so I was trying to have some worked around to make robotframework code trigger from springboot application and control ...
0
votes
0
answers
16
views
Create filter on Integer column (with default values selected) while creating pivot table using apache poi
I am trying to create filter on third field which is not included in Rows/Columns and that field is Integer. For String I am able to create it and it's working fine but for Integer it's not working.
...
-1
votes
0
answers
12
views
SecurityContextHolder.getContext().getAuthentication() is null
I am working on the Spring boot rest API with JWT Token to authenticate the requests. I have made multiple entries of Admin in DB and passing name as username, password as password in Basic Auth, but ...
0
votes
0
answers
17
views
Camera Access Failure after Migration to Android 14
I have recently migrated my Java 11 Android application from Android 13 to Android 14. As part of this migration, I updated the compileSDK and targetSDK versions to 34. Following the migration guide ...
1
vote
1
answer
20
views
Left join in Hibernate on the same entity and having other conditions
I need to do some performance fixes on java project with Hibernate 3.3.2 (upgrade not possible). There's an inner query - a not in condition. During a simplification process, I want to rewrite it as a ...
-1
votes
0
answers
14
views
Two rabbitmq queues with exactly same configuration one of them is not created automatically (Spring Boot 3 RabbitMQ)
I have 2 queues beans declared in one spring boot module, both queues have exactly same configuration in git. One of them is created automatically, but the second is not. Both queues have declared ...
0
votes
3
answers
62
views
Java: not-case-sensitive map key where key is Pair<String, String>
I have Map in Java:
Map<Pair<String, String>, MyClass> myMap;
I need the Pair to NOT be case sensitive.
The solution in case of regular string key is simple:
TreeMap<String, MyClass&...
0
votes
0
answers
6
views
Jndi connect to LDAP by GssApi KrbException: Server not found in Kerberos database (7)
I use GSSAPI to connect to LDAP.
JNDI connect to LDAP by GssApi KrbException: Server not found in Kerberos database (7)
This is my code:
URL url= this.getClass().getClassLoader().getResource("...
-4
votes
1
answer
31
views
Take an odd posivitve integer from input and print an odd numbered arrowhead pattern for it
it should be done without printing any other characters. Not even space
for example:
if the sample input is :
3
then the output should be :
1
333
1
sample input:
5
sample output:
1
333
55555
333
1
...
-1
votes
0
answers
16
views
Ibm Db2 Jdbc Connection [closed]
I I am getting below error Invalid operation: result set is closed. ERRORCODE=-4470, SQLSTATE=null at com.ibm.db2.jcc.am.b6.a(b6.java:794) Also the output is Start time: 2024-03-28T12:59:39.726 ...
0
votes
1
answer
37
views
Kotlin ArrayList.addFirst() is deprecated?
I'm trying to use ArrayList in Kotlin. Here is the code:
var list:List<PlcStoragePiece> = ArrayList()
list.addFirst(head) // head is a PlcStoragePiece
return list
BTW this is Java's ArrayList:
...
-1
votes
0
answers
12
views
Thermal Printing using TCP [closed]
I have a android app that prints a receipt bitmap and when im printing it using usb it prints and cuts fine, but print using TCP, it take so much time to cut the paper eventhough the receipt is ...
0
votes
1
answer
29
views
When adding an image to a pdf file using pdfbox the image is added without color, a part of the image should be red but it is black
I am using pdfbox to add a png image to a pdf file in java.
The image is added to the pdf and is displayed but with no color only black.
I changed a part of the image to Red but it still gets added to ...
-1
votes
0
answers
21
views
How to create test-jar with maven --also-make?
I have a maven module named synapse.
main
java
package1
A.java
test
java
common
C.java
package1
ATest.java
I wanted to create a non-executable jar containing all ...
3
votes
2
answers
83
views
Confusion of a code snippet in a interview
I was asked, in an interview, what the below code does.
class Case {
static int count1(int n) {
if (n == 0) {
return 0;
}
int m = n / 2;
if (2 * m != ...
-1
votes
0
answers
7
views
Consuming strapi API with Java - convert to java objects
I have a question about consuming webservices with Json/Gson because my new webservice delivers other strings than my old webservice. My new webservice is generated by Strapi 4 and I have not the ...
0
votes
1
answer
41
views
How do I find all non-overlapping combinations
Given a straight line of length N, the index position starts from 1 not 0.
Points are marked on this line using startIndex and endIndex pair.
Calculate the total number of non-intersecting pairs
...
1
vote
3
answers
52
views
Compare two different java collection objects with a common attribute using java streams api
I have two Sets containing 2 different objects
1. Set<A>
2. Set<B>
class A {
private String id;
private String name;
private B objB;
}
class B {
...
-1
votes
1
answer
19
views
Jackson: Deserialize object that might be wrapped
I need to process JSON from different sources who use different models. One ist sending me
{
"addressData": {
"street": "Foostreet 1",
"zip": "...
0
votes
0
answers
4
views
Android Studio Instalation Issues
I am installing and configuring Android Studio and Flutter to work in VS Code, but I get this error when doing flutter -doctor. I have tried everything I researched in many places, but the error ...
0
votes
1
answer
28
views
Where I use @ExtendsWith(MockitoExtension.class) and @SpringBootTest anyone clarify me with example
I'm beginner in Spring boot till now I have complete the REST Operations(GET,POST,PUT,DELETE) with MYSQL as a database and I want to write the unit test cases for Controller class and Service class I ...
0
votes
1
answer
12
views
test result: Error. Program `sh' timed out (timeout set to 480000ms, elapsed time including timeout handling was 480002ms)
When performing regression testing on OpenJDK, the error "--Fail: waitForJdbMsg timed out after 40 seconds, looking for /]/, in 1 lines; exitting" occurred when testing a shell script with ...