Latest Questions in Java

Browse latst posts in Java Category

92
Votes
Published 19 Sep, 2022
Java - POST InputStream with RestTemplate

I have a client that needs to POST a large number of large json files to a server. I've been able to get it working by reading each of the files into memory and posting the entire file with RestTempla...

57
Votes
Published 27 Oct, 2022
Java - How to access global non static variable from static method

I have main method in my java program, I want to store values in global variable because i want to access that values from different methods of the class, however I am not convinced to use static glob...

131
Votes
Published 19 Sep, 2022
Java - Java 8 Unsafe: xxxFence() instructions

In Java 8 three memory barrier instructions were added to Unsafe class (source): /** * Ensures lack of reordering of loads before the fence * with loads or stores after the fence. */ void loadFence...

100
Votes
Published 30 Oct, 2022
Java - How to extract timed ID3 metadata from HLS stream in ExoPlayer?

I have an M3U8 file located here: https://vcloud.blueframetech.com/file/hls/13836.m3u8 This video contains timed metadata every single second. My goal is to read this metadata from ExoPlayer. I curre...

58
Votes
Published 29 Oct, 2022
Java - Got java.lang.NoClassDefFoundError: org/apache/batik/dom/svg/SAXSVGDocumentFactory when using Interleaved2Of5 Barcode format

I am trying to print a list of barcodes, data for which which will be sent to the JasperReports jrxml in a List of Strings. I am successful in printing the barcodes using barbeque format, but now I h...

35
Votes
Published 28 Oct, 2022
Java - RabbitMQ Connection reset Exception

I have the same issue from this question: RabbitMQ Connection reset. My code is in kotlin and from https://www.rabbitmq.com/ssl.html#java-client-connecting. val connectionFactory = Connection...

71
Votes
Published 30 Oct, 2022
Java - Wildfly datasource does not connect to MySql database

I am completely new to Wildfly/JBoss so i am clueless what to do, i am sitting on this problem since yesterday noon. I am trying to use the mysql-connector-java-8.0.20.jar as the connector and my Wil...

34
Votes
Published 30 Oct, 2022
Java - Generate a excel using java and create a macro in the excel

I have a java code that takes data from MongoDB and later creates an excel(.xls) containing this data using Apache POI but in a formatted manner. My final requirement is to mail the last worksheet i...

76
Votes
Published 30 Oct, 2022
Java - Java - Parse delimited file and find column datatypes

Is it possible to parse a delimited file and find column datatypes? e.g Delimited file: Email,FirstName,DOB,Age,CreateDate [email protected],Test User1,20/01/2001,24,23/02/2015 14:06:45 [email protected],...

60
Votes
Published 29 Oct, 2022
Java - Which data structure to use to store millions of objects in multithreading environment ( Scalability and performace )?

My requirement is like : I want to perform frequent operation on millions of objects in multi-threaded environment with concurrency and scalability keeping in mind, I need best data structure suitable...

102
Votes
Published 29 Oct, 2022
Java - Java stream groupingBy key as max salary employee and value as all employee of department

I have a list of Employee public class Employee { private String name; private Integer age; private Double salary; private Department department; } List<Employee> employeeList = Arrays...

101
Votes
Published 07 Sep, 2022
Java - How to filter a PostgreSQL array column with the JPA Criteria API?

I am using: Hibernate 4.3.5 Spring JPA 1.6.0 Javax Persistence API 2.1 The "refcodemailing" column is defined as an array of int: int[] My entity object: @Entity @Table public class CalendarEven...

99
Votes
Published 06 Sep, 2022
Java - how to add .crt file to keystore and trust store

I am having a .crt file and I wanted to import to keystore and truststore using java(first create keystore and truststore then import). Below is the code that I am using: import org.glassfish.tyrus...

122
Votes
Published 19 Sep, 2022
Java - Error:No such property: GradleVersion for class: JetGradlePlugin

I am getting below error in intellij for a gradle project. I am importing existing gradle project and trying refresh it in gradle window. Error:No such property: GradleVersion for class: JetGradlePlu...

40
Votes
Published 26 Oct, 2022
Java - How to merge two execute two reactor fluxes in parallel that return lists and merge the results

I have a LegacyAccountDto that I need to build a list of from two separate sources. One is a local JPA repository and the other is a web service call. The web service version has the accountStatus a...

69
Votes
Published 27 Oct, 2022
Java - How to use different tablespaces for tables and indexes with liquibase in Java

I'm using liquibase (3.6.3) in Spring Boot (2.1.8) java (1.8) application for managing database (Oracle 12.2) schema changes. My liquibase changesets does not contain 'tablespace' params and all data...

64
Votes
Published 19 Sep, 2022
Java - java.lang.IndexOutOfBoundsException: setSpan (N ... N) ends beyond length 10500

I get this exception when I call EditText.setSelection() java.lang.IndexOutOfBoundsException: setSpan (N ... N) ends beyond length 10500 N can be any number. For example if I call setSelection(1047...

85
Votes
Published 16 Sep, 2022
Java - What is the difference between `bitCount()` and `bitLength()` of a `BigInteger`

The descriptions of bitCount() and bitLength() are rather cryptic: public int bitCount() Returns the number of bits in the two's complement representation of this BigInteger that differ from...

56
Votes
Published 26 Oct, 2022
Java - Logs are not loading according to Log4j2.properties

I am upgrading to Log4j to Log4j2 in my project. I have put log4j2.properties in the classpath, and its loading. Despite that logs are not coming according to properties defined in log4j2.properties....

22
Votes
Published 19 Sep, 2022
Java - Deploying my application at the root in Tomcat

I have the war file of my application. I need to deploy this at the root level. The current URL is http://localhost:8080/war_name/application_name.