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
answer168
viewsHow to find and change a pattern without replacing the other elements of a String with regex?
I have a template qualquer nome:{{UDA_numero qualquer}} that comes "loose" in a String. In that String, there can be "n" templates, words, numbers, etc. The goal is to catch this "any number" from…
-
1
votes0
answers18
viewsLoad URL into htmlText tag
I need to upload a url inside this tag: <mx:HBox id="horizontalBoxInfo" width="100%" > <mx:TextArea id="textAreaInfo" width="100%" height="200" editable="false" horizontalScrollPolicy="off"…
-
1
votes1
answer436
viewsString error using the nextLine() method in Java
I have a problem with a simple java program. When I run and scan with String, it simply goes straight to the end of the program, but when I put char it does not pass and runs normally, even so I…
-
1
votes1
answer90
viewsAbout implementation using spring
Hello, I need a help, I have a bank with two tables 1-Institution 2-People, for that I created in the model these 2 classes do not know if it is the right way more I did so. I created the Repository…
-
1
votes0
answers33
viewsReal-time upgrade firebase
I have a method that I want to check at all times in the database if a field of the child node is modified (in this case, the "status" field), when it is changed, I want the text on the android…
-
1
votes1
answer101
viewsMVC and JAVA doubt
Giving continuity to a project of the college that was stopped, I intend to do it in Java already I did and I remade from scratch about 2 times however, it was horrible and to each class I realized…
-
1
votes0
answers666
viewsHow to test one method that depends on the result of another with Junit?
Greetings, I have a class that does actions in an email. I created some tests for this class and would like to know if this is a valid form of testing or if there is any better way to do it. I test…
-
1
votes1
answer505
viewsHow to create a . JAR for test automation?
Hello, I am creating automated scripts using Selenium Webdriver and I am running within the Intellij IDE. I would like to know how it is possible to create a . JAR file from my scripts, so it would…
-
1
votes1
answer49
viewsDoubt about the Controller in spring mvc
Hello. I am studying the spring mvc and I am a few questions about its functioning. One of them is on the part of the controller. When I fill out a form and request a controller method, are all the…
-
1
votes2
answers962
viewsValidating null and/or empty fields when creating Java objects
I have an object and would like to force the filling of attributes at the time of the creation of the object. What is the best way to do this? There are the annotations @NotNull, @NotEmpty and…
-
1
votes1
answer72
viewsHow to leave default value in Static Arraylist in Java?
I am making a program with login screen and have a question: I want settar an "administrator" account in a ArrayList static and do not know how to proceed (or if this would be something plausible).…
-
1
votes1
answer120
viewsSend Ajax data to controller and return values
My project is a Struts application, and my problem is that I’m not getting the return of the back-end method for the ajax method in the graphical interface, and I’m needing the modal form to return…
-
1
votes1
answer1505
viewsHV000030: No Validator could be found for Constraint 'javax.validation.constraints.Email' validating type 'java.lang.String'
I’m in a class AdministradorDTO and added some validators to it I found a tutorial on the Internet and I followed the same way in my case it gives this error in the email, before it gave in String…
-
1
votes1
answer32
viewsMutablelist<Int> cannot be Invoked as a Function. What do I do?
package com.example.app.views import android.app.DatePickerDialog import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.view.View import android.widget.ArrayAdapter…
-
1
votes1
answer171
viewsHow to change an image dynamically when a button is pressed and save the state of that image
I have a problem where I need to alter an image of a imageView when the Button is pressed and when it is pressed again change to the image that was previously. I even managed to do this through the…
-
1
votes1
answer163
viewsChange super class value using subclass method
The method sacar() does not work, does not change the value of the balance. I make the deposit using super class method ContaBancaria direct, the sacar() is of class ContaPoupanca that extends the…
-
1
votes1
answer1484
viewsHow to read a float with Scanner
My problem is this: package com.vreawillsaveyou01; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); float number =…
-
1
votes1
answer129
viewsImages and css do not load on the page when executed by the jar
Hello, I see you’ve had similar questions to my own but you haven’t answered my question. I’m developing an API that goes into a database, takes the data and returns a pdf report using Thymeleaf and…
-
1
votes2
answers188
viewsCalculator in Java
Everything was going well until the part where the result should appear. public static void main( String[] args) { Scanner in = new Scanner(System.in); int num1,num2,resul; String sinal;…
-
1
votes1
answer160
viewsAutomatic sum of two Edittext to put result in a Textview
I want to take two values out of two EditText and put the result of these two values into one TextView. I made that code but this giving error editPecaBoas = findViewById(R.id.editPecaBoas);…
-
1
votes1
answer1219
viewsString readline() in Java
I’m having difficulty instantiating the readline() method correctly in java so that you read the file, run the while loop and write the desired data. If anyone can help me, I’d really appreciate it!…
-
1
votes1
answer137
viewsSave a date value in the firestore
I’m trying to save a data value in the firestore, but I’m having a conversion problem when I take the value of a EditText and send it to become a date type value. The attempt I made was this one.…
-
1
votes0
answers25
viewsProblems retrieving the Datatable object in P:Dialog
I have a datatable that lists all the students, and I have a button that opens a modal, in this modal I want to continue manipulating my datatable object, for this I use the…
-
1
votes1
answer129
viewsHow to set instance variable using the read value of a Scanner?
To declare the value of a class instance variable Paciente by class Main with the Scanner in Java? Codes: public class Paciente{ private double cod; private String nome; public getNome(){ return…
-
1
votes1
answer614
viewsProblem with CORS
I’m making a request through the Angularjs at port 3000: function _registrarNovaAposta(aposta) {return $http.post("http://localhost:8080/sga-api/apostas/nova-aposta", aposta);} to the endpoint:…
-
1
votes3
answers219
viewsGet maximum table value (JPA) with Java 8
I have a method in my DAO class that returns a general list of the table: public List<ObjetoRisco> findAll() { return manager.createQuery("select o from ObjetoRisco o",…
-
1
votes2
answers798
viewsGet Imei on Android using Java
I’m needing to get a unique identifier for my app, I’m trying to get the device IMEI and I’m not getting, below follows the code I tried to get the IMEI and it always stops at the first if that has…
-
1
votes1
answer139
viewsException in thread "main" java.awt.Illegalcomponentstateexception: The frame is Decorated
Guys I came back, I started studying AWT I made a simple program that just opened a window with a green background, but I try to create an event to the program window close and is giving the title…
-
1
votes1
answer422
viewsHow do Extent Reports generate an HTML report when the test fails outside the @Test tag?
I created a report template for my test project that is up to now meeting my demand, however, if the test fails outside the@Test tag the report is not generated (being some connection error, or…
-
1
votes1
answer261
viewsHow to write an Enum to the database with JPA and Postman
I am creating a product register, and when I pass through Postman the JSON of my product to be recorded, its type is being saved as NULL. The product types are an Enum, I will put down the code I…
-
1
votes1
answer51
viewsWhy can’t I give getTransaction(). Begin() were from a Main?
I’m playing with Hibernate and I came up with a very amateur question. Before I was creating a DAO, and in it I received an Entitymanager from my test class, by the constructor: public class…
-
1
votes2
answers83
viewsIs it possible to pass an array per parameter without instantiating it?
I wanted to pass one vetor (or a ArrayList) per parameter without instantiating it, but I’m quite lost on this, because usually I instate an object list and I add the data in this list, but as I…
-
1
votes5
answers578
viewsHow to validate when Resultset does not find any value?
I’m trying to build a Java function pesquisarCliente where it must be consulted in the Database whether it exists or not. If there is more than one result you should return all records, if you do…
-
1
votes1
answer114
viewsorg.springframework.Beans.factory.Beancreationexception: ERROR
Complete error: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'applicationStart': Unsatisfied dependency expressed through field 'repository';…
-
1
votes1
answer62
viewsHow to add an array of objects on a grid line of a java Jtable
I have a code snippet that works as follows: protected void listaTodosRegistros(boolean bAberturaConsulta, JTable tbGrid, boolean bFiltraTodos) { DefaultTableModel modelo = new DefaultTableModel();…
-
1
votes1
answer57
viewsWhy does spring data persist when I use a set?
I have a method more or less like the following within a service: @Transactional public void atualizarPosicoes(Integer novaPosicao, Long idTarefaAtualizada){…
-
1
votes2
answers960
viewsClass X Diagram Entity-Relationship Diagram
I’m stuck in the POO X Relational Database. To better substantiate my inquiries follows, in first some (simplified) modeling I did: 1 - Class diagram Possible programming for this diagram: 1.1 -…
-
1
votes1
answer58
viewsSpecial Character with Scanner and Filereader
I have a.txt file with the following values: TESTE 17,00% 01/01/2014 25,55 AÇAILANDIA When importing this txt in my Java application the special character Ç is not imported and the result is like…
-
1
votes1
answer78
viewsjSSC does not find the USB ports of my PC
I am doing a project in Java using the jSSC library, but when I use the method of listing the ports nothing appears. I tested on another computer and worked perfectly, but on my personal computer…
-
1
votes2
answers2509
viewsHow to add 64-bit and 32-bit native codes to an Android app?
I’m having trouble publishing an app version. The Play store is notifying me about the new 32-bit and 64-bit architecture: "This version does not comply with Google Play 64-bit requirement The…
-
1
votes0
answers35
viewsError loading image in application by Json request
I am developing an application that captures pictures sends to the server, the server saved in the database, and when the user wants, he can download these photos again on his mobile phone. Even the…
-
1
votes0
answers41
viewsHow to mock a method that has varargs as arguments?
I would like to mock this method: @Override @Transactional(propagation = Propagation.REQUIRED, readOnly = true) public List<E> buscarTodos(String ... sorting) { Sort sort = null; if (sorting…
-
1
votes0
answers56
viewsByte[] to image conversion returning null
I am developing a mobile application that send photos of the application to the server, made in springboot. When receiving the request with the image, via json, I try to convert String to Image.…
-
1
votes2
answers105
viewsMore appropriate way to name a list
Hello I would like to ask a question about attribute names. What would be the most appropriate way to name a list? Let’s assume that I have an attribute which is a list of Ufs. What would be the…
-
1
votes1
answer190
viewsHibernate can’t find an existing column, ERRORCODE=-4460
I am having a difficulty in my system where SQL with Hibernate can not find a specific column by Java, the same query returns the right result when rotated by SQL. IDE used is Netbeans. The query is…
-
1
votes0
answers714
viewsError accessing Webcam.js - Error: Webcam is not Loaded yet
I’m getting this error while accessing Webcam.js Error: Webcam is not Loaded yet I’m already using secure connection plus error persists. I’m using Primefaces, the component photocam. Application…
-
1
votes2
answers331
viewsWhite screen before splash screen startup
I created a Splash Screen that works normally, but when opening the application instead of directly entering Splash, it runs a white screen. Splash.xml <?xml version="1.0" encoding="utf-8"?>…
-
1
votes1
answer135
viewsError returning objects saved in database between activites - Null object
I’m developing a simple application to fill out a form, display the registrants and edit them. I’m using the one-to-many relationship where a patient can hold multiple photos, photos that are being…
-
1
votes0
answers30
viewsJava logic problem
Good evening my dear I’m having a problem with the logic of this program which is a clock: private void updateDisplay() { if(hours.getValue()==0 && (periodo=="am" || periodo =="AM")){…
javaasked 5 years, 1 month ago Renan Avila 19 -
1
votes1
answer2479
viewsGenerate even and odd random numbers with defined quantities
How to generate random numbers with Random and limiting the number of odd and odd pairs? Example: 50 numbers should be generated in total, being 20 pairs and 30 odd. public int GeraVetorParImpar() {…