Most voted "java" questions
Use this tag when the question refers to some resource, information, or problem relating exclusively to the Java programming language. Java is a class-based, statically typed, reflective, and execution environment (JRE) language. Java programs are compiled to bytecode and run on a virtual machine (JVM), allowing a "write Once, run Anywhere" philosophy (WORA).
Learn more…14,468 questions
Sort by count of
-
1
votes1
answer2137
viewsMethod Matches() to validate if string contains only numbers
I’ve read some articles on the method matches() and really didn’t understand. In that code would return false because I am using a variable and the method read the variable name and not the value…
-
1
votes1
answer85
viewsHow to get the value of a specific parameter in a jointpoint in an "Around" processing?
I have the following method: @RequestMapping(path = "/{tenant}/import", method = RequestMethod.POST, consumes = "application/json", produces = "text/plain; charset=UTF-8") @Transactional public…
-
1
votes1
answer159
viewsjava.lang.Classnotfoundexception: android.support.v7.widget.Toolbar
OFFICIAL ANDROID DOCUMENTATION ABOUT TOOLBAR I’m following the official documentation of Android, and even so I’m having problems as it generated this error. Caused by:…
-
1
votes2
answers83
viewsselectOneMenu with convert does not work
I have a selectOneMenu where I am populating with the database data but the same is coming with the memory address (see image), and not the value I want. I tried to solve using the example of this…
-
1
votes1
answer101
viewsHow to show icon images in Android Action Bar?
I created a simple application, it is something very trivial. What is happening is that I am trying to create a menu with icons on Action Bar, but what is actually happening is that my application…
-
1
votes0
answers69
viewssend a message from the server to the Sockets client
I recently started working with sockets this week and am having difficulties. My goal is when the client sends a message the server responded with a notification. On the client side, sending to the…
-
1
votes1
answer3128
viewsError 'Noclassdeffounderror: org/springframework/boot/context/properties/Configurationpropertiesbean'
I am trying to make an application with several packages and using spring cloud with Eureka in java, but this exception. org.springframework.beans.factory.BeanCreationException: Error creating bean…
-
1
votes1
answer769
viewsException in thread "main" java.util.Nosuchelementexception: No line found
I am new in programming and the problem asks to store in vector the name of 10 products. Then the program must request the range of products that must be displayed (for example: 3 to 7). The error…
-
1
votes1
answer54
viewsHow to open files with accent on name - Filenotfoundexception
The path to the files are in a String array. Some files have accented name and are generating FileNotFoundException /** * Realiza leitura dos dados de um arquivo. * @param s - string com endereco do…
-
1
votes0
answers167
viewsJava Pool Hibernate c3p0
Dear friends, good afternoon. I have a Java solution that’s generating production problems, taking down the bank. After a few changes, I set up a pool using Hibernate c3p0 to manage the number of…
-
1
votes1
answer57
viewsI’m not able to create array with keys in Java
I am studying the Java language and to practice I am creating a simple login program. I have a class called Database that should save an array with the information (name and password) of the users.…
-
1
votes0
answers16
viewsImageio.read returns null when Inputstream use jersey
I have the following problem I have the following service: @PUT @Path("/validateQRCode") @Logging @Permissions(allAllowed = true) @Consumes(MediaType.MULTIPART_FORM_DATA)…
-
1
votes1
answer100
viewsI understand that the post method is getting it wrong at Postman
My controller package br.com.clinicamedica.controller.especialidade; import static org.springframework.http.HttpStatus.CONFLICT; import static org.springframework.http.HttpStatus.OK; import static…
-
1
votes1
answer84
viewsHow to delete data from Jtable and insert it again?
Through a button that has Coo function update the table I want the data to be removed and then come back, my code until then this so: public class atualizando implements ActionListener { @Override…
-
1
votes1
answer165
viewsChoose between two numbers in Java
I’m building a game in which I want an object with given coordinates on the ground to spread, creating more pixels of himself on the ground. Each pixel of which would be represented by number 4.…
-
1
votes1
answer35
viewsDynamically set the height of a band on Jasperreports
I am doing a project to facilitate the creation of reports with DynamicJasper and got to a part where I have to position an element that is in Band PageHeader manually, setting the position X and Y,…
-
1
votes1
answer71
viewsJava - Thread Synchronization Questions
I have the following classes: Vehicle (Vehicle): public class Vehicle { private String chassis; private String type; private double topSpeed; public Vehicle() { } public Vehicle(String chassis,…
javaasked 4 years, 6 months ago Aitor Ruiz 11 -
1
votes2
answers286
viewsRemove characters that are before another
My teacher asked to make a method that cancels a character in a sentence using the # cancels the previous character, example: Entree: PUO#C MIP#NO#AS Exit: PUC MINAS However, my code gives error…
-
1
votes1
answer210
viewsThread Pool for multiplication of arrays in java
In short: How can I split matrix operations and pool threads with a fixed amount of threads using the amount of user cores? I’m cracking my head, looking at the gringo SOF, but nothing that clears…
-
1
votes0
answers91
viewsCorrection of Service Spring Boot methods
Good evening, I am creating an API with spring based on a course. However, it has some methods that are possibly depreciated in the version I am using(2.2.6) course version(1.5.10). I need to apply…
-
1
votes1
answer90
viewsInvert string containing numbers
Using this code as a test, whose goal is to invert a string containing numbers. Input: 0123456789 Output: [57, 56, 55, 54, 53, 52, 51, 50, 49, 48] unlike [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]. public class…
-
1
votes1
answer241
viewsUsing Loop to traverse an array, stopping at the first item and waiting for a click to the next JAVA item
Good evening, folks, I’ve been trying to find a solution to my problem for three days without success. Let’s get to the problem. I have an external API that is on a server, I can already make the…
-
1
votes1
answer105
viewsRegex to select only a number within certain Strings
I have a multi-line log that generates multiple events, however I need to take the . and take only the information that is before the "ms", ie "509833", "780414", etc. 2020-04-23 15:21:10,602 INFO…
-
1
votes0
answers44
viewsHow to query database postgres from web java
I want to do a database search from my HTML page by typing the first letters (eg and%) and in the table should appear the list of words starting with the typed letter: My database is Postgresql.…
-
1
votes1
answer641
viewsPrint in descending order in Java
I’m trying to create an interface where notes (decimals) are typed, and printed in descending order, but I’m getting some errors that I don’t quite understand. This is the class for the user to type…
javaasked 4 years, 5 months ago Arthur Rocha 11 -
1
votes1
answer89
viewsFilter files by their extension(xml, rar, docx....)
Good Afternoon, I have an algorithm that takes all the files of an x directory, and reads them, but these files have to be XML, and sometimes RAR files appear, then at the time of reading give error…
-
1
votes1
answer91
viewsJava problem n + 1 query with Map
I have a performance problem where I have 10 rental cars and need to popular a graph of lines with these 10 cars however it is taking a long time to open the screen. Follow the logic I used to make…
-
1
votes1
answer315
viewsUnit test (Junit and Mockito) - Clean & maintainable test code requires zero unnecessary code
I am writing the test of a findByID method(): public DoctorDTO getDoctorById(long id) throws DoctorNotFoundException { Optional<Doctor> doctorO = VerifyIfExists(id); return…
-
1
votes1
answer50
viewsIs it possible to create a Java superclass for basic CRUD functions using spring framework?
While working recently on a project, I noticed that we have several classes with basic CRUD and repeating functions, their only differences, would be some parameters, responses and function calls in…
-
1
votes1
answer24
views(Java) Error while continuing to traverse TXT lines
good night! I need that even if it reaches the condition total_min < 720 He keeps going through the lines. The 720 are the total minutes before lunch, when reached should separates the activities…
-
1
votes1
answer223
viewsImport problem when compiling classes in different packages
I have a problem with import of a package that I created in Java, the project directory tree is this: . ├── CsvFiles │ ├── 01 │ ├── 01.zip │ ├── ALPOO_GRADUACAO_2018.csv │ ├──…
-
1
votes0
answers25
viewsJava criteria return Function
I have a call to a function to the database using criteria, but I can’t get the result that returns in an Expression, my doubt and how to get the value returned by Expression? public…
-
1
votes0
answers227
viewsHow to hide the navigation bar?
I used this code below to hide the Android navigation bar. The code worked, but when a new Activity is opened by an app button the bar appears and comes out fast, this is not very good. So I’d like…
-
1
votes1
answer80
viewsRecyclerview - Is it possible to change the current view in the long click event?
In a certain part of my app you will get a Recyclerview as a list of expenses as shown below: The point is, I want the user to be able to edit expenses at any time just by having a long click, thus…
-
1
votes1
answer97
viewsJdesktoppane does not remove closed screen rendering, how to proceed?
I created a basic screen with Netbeans that has a menu and a JDesktopPane that opens the JInternalFrame menu-referenced: As well as a function to open these JInternalFrame: private void…
-
1
votes0
answers31
viewsDijkstra Algorithm with Priority Queue - Why and Poll are not working, is my logic wrong?
I’m trying to apply the algorithm of Dijkstra using Priority Precise to leave it with logarithmic complexity T(N) = E*log(n) The first node manages to find its neighbors and relax its values but the…
-
1
votes1
answer75
viewsSplit String into blocks, considering only letters or text in square brackets
If I have a string like that: "Olá, o meu nome é [José Cavalo]" And I der split: {"Olá,", "o", "meu", "nome", "é", "[José", "Cavalo]"} First of all, we have a problem. At 0, we have "Olá,", and we…
-
1
votes1
answer62
viewsSending HTML email in Java project
I’m having to develop a system that makes a query in a database and the results are sent by email, for formatting we use HTML, the first way I saw was to store the HTML code in a variable, but the…
-
1
votes1
answer132
viewsRemove duplicate values in a list and print them
I have a file called arq1.txt and the other arq2.txt. Values within the arq1: 2 5 1 10 21 7 8 8 3 Values of arq2: 1,2,3 In this case, my job is to compare the values present in the 2 files and…
javaasked 4 years, 2 months ago Gustavo Moret 11 -
1
votes1
answer78
viewsThe program hangs when it arrives at the while
I made a basic program about calculating potentiation, but when it comes to while crash, and until the terminal I have to restart. So I can’t continue the program. I even tried to change the way the…
-
1
votes1
answer128
viewsHow can I improve this code?
I am learning java and I found this challenge but when finishing I thought that the code was very polluted but I can not think of how to improve, I believe that using POO would be much easier but I…
-
1
votes1
answer46
viewsI cannot upload two files to the same document in a Manytoone interface
Hey, guys! Good night. So I have an entity called files and another entity called document. A document can have multiple files. I made a file upload module. The problem I’m facing is that when I…
-
1
votes0
answers21
viewsObservers can be injected into the observable?
It’s a half-ass question whose answer might be "make the most sense of the code," but it doesn’t hurt to ask. The pattern Observer suggests that an observer register (via…
-
1
votes1
answer259
viewsMake a Map and take the values
I have a Map and within it I have another Map and I need to make a for and take the values that are in those maps, how it can be done? The structure and shape that the Map is created like this:…
-
1
votes0
answers49
viewsTwo observable watching each other? Or something different from that?
Consider a class ServidorTcp (I don’t know if this is the right abstraction; it would have two operations, iniciar() and parar()). Inside there’s a field socketServer whose type is SocketServer (a…
-
1
votes1
answer80
viewsClass that implements Comparable must compare by a String field in lexicographic order
How do I order a list of people by name? For understanding, follow the code: public class Pessoa implements Comparable<Pessoa> { private String nome; private int idade; private String sexo;…
-
1
votes0
answers35
viewsJava Producer and Consumer with same production and consumption rate, despite different speeds
Hello! I’m starting to use BlockingQueue and ExecutorService to implement a Producer-Consumer. Looking at the page https://is.gd/BcIIXK, I removed line 24, and changed line 38 to…
-
1
votes1
answer57
viewsDoubt about Android Activity syntax and the "onCreate" method and what are its arguments!
I’m new to the programming world and I’ve been studying java. I’m wanting to understand the Java application for Android apps and came across these methods from Activity. The theory I understand…
-
1
votes1
answer71
viewsError picking value returned with query.getResultList(). get(0)
I need to get the value of a query, simply a field and I’m making the following mistake: java.math.BigDecimal cannot be cast to java.lang.String. My DAO is like this: public String…
-
1
votes1
answer76
viewsJava Array Storage Error
I am making a code where the user needs to define a vector of size N, and fill it, however, after informing the vector size, and informing the first value, the following error appears: Exception in…