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
answer55
viewsError adding to a List in JAVA
I am trying to add a value to a list but am getting the following error: Cannot invoke "java.util.List.add(Object)" because "[]" is null The code is this: static void montaEl(int tam, Elemento el) {…
-
-1
votes1
answer39
viewsDoubt comma, decimal places Java
I’m having some doubts, could you help me please. First: When entering the entry amount. Enter the salary of the first employee: 12854,89 I CAN’T PUT A COMMA TO ADD THE NUMERICAL VALUE. Second: When…
javaasked 3 years, 9 months ago Gabriel Henrique 1 -
-1
votes2
answers19
viewsIntellij - Java Error - Gradle Sync failed: Cannot Convert relative path ~/GRADLE_HOME/daemon/6.8 to an Absolute file
The problem is appearing whenever I try to run the program, and the Packages program do not appear either. I opened the same project by Vscode and worked normally there, just not working by…
-
-1
votes0
answers26
viewsDifficulty with Double handling in Java
I’m getting the value 99999912343000007654329925.7865, declared as Double, but in time to print it I get 99999912343000000000000000.0000. The error is in or out of that number? Follow the code:…
javaasked 3 years, 8 months ago josemaria512 1 -
-1
votes0
answers9
viewsError: Could not find or load main class
I started doing some exercises of a book I’m following in Java, everything was fine, until yesterday I was compiling and running the good programs. Then today DO NADA stopped running the programs to…
javaasked 3 years, 8 months ago PaulimCódigos 1 -
-1
votes0
answers10
viewsProblem with connection between Java and Mysql using Hibernate
Hello I am trying to make a connection between Java and Mysql, and this appearing the following error: ago. 13, 2021 10:55:09 PM org.hibernate.jpa.internal.util.LogHelper…
-
-1
votes1
answer17
viewsHow to define which data of an ENUM the JPA will persist in the bank?
Hello, I would like to know how to annotate a property (ID) of my ENUM for when to persist in the bank? Because currently JPA is saving the index of the Enum array and not the ID... My Enum: @Getter…
-
-1
votes0
answers5
viewsGenerate Pdf of the page with listview android studio
I am facing difficulties to adjust an application page layout in android studio, generate image and save in pdf. I have a layout with several Textview and a Listview with scrolling, I can transform…
-
-1
votes0
answers11
viewsBuild error in android studio using Kotlin
When I compile my application it does not build and from this error, how do I fix? in another application it works. java.lang.Assertionerror: annotationType(): unrecognized Attribute name MODULE…
-
-1
votes0
answers8
viewsHow to do Junit in this method?
I’m learning Junit and I’m trying to test the toString method, but I can’t do it. I would like the help to understand where and how I should begin. Follows code below public String toString(){…
-
-1
votes0
answers14
viewsResponse print of the Rest Assured being printed with encoding
@Test public void testValidarObtencaoToken() { response = post(UsuarioFactory.setBodyUsuario("rfrffr", "rfrffr", "rfrffr"), "/usuarios"); System.out.println(response.getBody().asString()); } Console…
-
-1
votes1
answer19
viewsWhen and how to use @Value Spring Boot?
Hello! I am doing the validation of vulnerabilities pointed out by Sonarqube in an API, and Sonar presented the following problem for the variables and objects: With the following suggestion for…
-
-1
votes0
answers23
viewsDoubt in JAVA Code
I am developing a simple program for inventory control, it has to have an option for price adjustment and in the report that program prints have to have the balance of all the prices of the products…
javaasked 3 years, 7 months ago João C. Menes 1 -
-1
votes0
answers13
viewsCould someone help me with a class diagram?
In a class diagram how to place chat online?
-
-1
votes0
answers7
viewsError When Constructing Menudinamico
See that I have a table of Menus I have a Bean that reads this table and builds the menu according to two information, these being: If the user is an INTERNAL, EXTERNAL user. If the Menu is for…
-
-1
votes0
answers23
viewsRegex to get a dd/MM/yyyy date by ignoring characters in the middle?
In this case I can have a string like String data = "20/dsauh'03*/2021"; My idea was to do something like: Pattern p = Pattern.compile("([0-9]{1,2}\\/[0-9]{1,2}\\/[0-9]{4})"); Matcher matcher =…
-
-1
votes3
answers377
viewsProblem with array in Java
I am trying to create a calendar of contacts in java, I am using some classes that were requested in the exercise. the main class: import java.util.Scanner; public class Lista15Q03 { public static…
-
-1
votes1
answer47
viewsJAX-RS Rename Set
I created a project using JAX-RS to make a web service REST and it works, I can access the result in a resource and everything but it comes like this: { "carroes": { "carro": [ { "@id": "1",…
-
-1
votes2
answers99
viewsIcons in actionbar do not appear
I have a Fragment and I’m putting these two methods in the class @Override public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { menuInflater.inflate(R.menu.alerta, menu);…
-
-1
votes1
answer316
viewsHow to import a csv file to a Jtable?
Does anyone know how to move from a csv file to a jtable? Currently but lists everything in the first column. private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your…
-
-1
votes2
answers55
viewsswitch not recognizing ENUM as constant
public enum enumUpdateAction { NEW(0), CHANGE(1), DELETE(2), DELETE_THRU(3), DELETE_FROM(4); public int codigo; enumUpdateAction(int codigo) { this.codigo = codigo; } public int getCodigo() { return…
javaasked 8 years, 1 month ago Marcos Vinicius 41 -
-1
votes1
answer954
viewsManytomany mapping with additional column
In my study project, aimed at controlling football matches, I have the following entities: Gambler Name; Departure Date of implementation; Gols pro; Goals against; I still need to record the goals…
-
-1
votes1
answer410
viewsHow to access another class member?
I have a JPanel which contains all graphic elements, input text fields etc. This is a different class, which needs to know all the attributes of the Jpanel. The problem is that you are not accessing…
-
-1
votes1
answer1234
viewsHow to clean an int variable in java?
I am developing a program that has a menu that if I type 1 register a course and if I type 2 enrollment a student both ifs are working type if I type 1 register a course close the console open again…
javaasked 8 years, 1 month ago Douglas Sabino 23 -
-1
votes1
answer645
viewsAjax with java, via jsp
need to pass the information of a component that is on the jsp page to a controller that is in java. From what I understand the best way is via AJAX. Municipal component <label…
-
-1
votes1
answer112
viewsSearch by date does not work
I am trying to do a search in the mysql database doing a filter by date and is not bringing any results. On the screen below I was able to search for the other criteria This is the code that’s doing…
-
-1
votes1
answer612
viewscall a screen with only buttons and methods
I need to create a screen that calls another, but I want to do it using only methods, and in the code I did it is not calling the other. On the first screen I have a list and a button include. When…
-
-1
votes2
answers454
viewsReturn an SQL result
I have a query in sql that is returning me in a wrong way. He’s returning like this: [Cidade.Cidade@1d8b06a, Cidade.Cidade@251a5c, Cidade.Cidade@15ec3c1 and I’d like you to return like this…
javaasked 7 years, 11 months ago Diego Gomes Dias 3 -
-1
votes1
answer52
viewsError of Circularreferenceexception
I need help, I’m with this : com.thoughtworks.Xstream.core.Treemarshaller$Circularreferenceexception And I can’t find the solution. This is the excerpt from the code : XStream xstream = new…
javaasked 7 years, 10 months ago Mateus Veloso 1,852 -
-1
votes1
answer267
viewsJtable only accept float numbers in your cell
I’m using this code to accept only numbers in the jtable cell, but I’d like to know how to accept . too. Someone can help me? I’m using Java Language on the netbeans platform. TableColumn col =…
-
-1
votes1
answer549
viewsGenerate report only with data passed via Ireports parameter
Normally we generate report by Ireports based on database query, only now I come across the following question, I will assemble a report based on the data shown in the customer’s look, in case it is…
-
-1
votes1
answer193
viewsInsert a Splashscreen or imageView into app crosswalk webview
I have a crosswalk webview application. as my site takes about 5 seconds to open on screen, I thought about inserting a splashscreen or imagemview ( I don’t know if there’s a difference between the…
-
-1
votes1
answer84
viewsWhy is this result giving as 0 in Java?
I’m making a program where you have a small and simple calculator, basically the user will have the mathematical expressions (+,-,*,/) and you can choose between one of them and then the result will…
-
-1
votes1
answer51
viewsPage does not list items
For some reason the XHTML page does not list the items from #{nomesMB.nomes}. Codes: XHTML: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"…
-
-1
votes1
answer478
viewsHow can I run a class (build a Jframe with browser) through an actionPerformed button?
I am building a java application that has a browser built through a java class. I want to know how I can call this class (executable class) through an actionPerformed of a Jbutton, that is, when I…
javaasked 7 years, 8 months ago Vinicius Viana 1 -
-1
votes1
answer49
viewsData search
good guys to with doubt here and I want to do the following in jsp I want the client to type One word to search mysql database example Eonardo then I will have several registered names of the…
-
-1
votes1
answer719
viewsPass text to an Edittext
I’m making an android app that reads a barcode. I saw a video on Youtube that taught how to do and replicated to take as a basis and worked well. The problem was when I tried to put the read return…
-
-1
votes1
answer57
viewsProgramming with android studio
I am having error in my project, the error that appears is the following: ->/ Error:(23, 31) error: ';' expected/ package com.example.lorenzo.pulo; import…
-
-1
votes1
answer547
viewsFormat measurement field with Jformattedtextfield
I’m trying to create a field to take measurements, I wanted to apply a mask so that it would look like this: The field already starts with 0.00, then if you type value it keeps formatting. And when…
-
-1
votes1
answer135
viewsCheck null, how to proceed?
How to put to check if the cell is empty in this method? public void VerificarResultdo() { int linha = CadresultadoTabela.getSelectedRow(); int coluna = CadresultadoTabela.getSelectedColumn();…
javaasked 7 years, 8 months ago Rafael Chaves 33 -
-1
votes1
answer1275
viewsCalculate annual salary
• Model an employee. He must have the employee’s name (String), the department where he works (String), your salary (double), the date of entry into the bank (String) and your ID (String). • Create…
-
-1
votes1
answer50
viewsIs there any connection between these two elements of the HTML code?
I’m pulling data from a website with Jsoup but I’m not very good at html. I would like to know if there is any relationship between ".Lin-area-C2" and ".Lin-course-C3". If there is, I’d like to know…
-
-1
votes1
answer450
viewsHow do I get the Calendar date on Android?
I got it inside the onCreate: final DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear,…
-
-1
votes2
answers103
viewsCode always falls on the same if
Why the method souVelho() only returns the answer "You’re new." regardless of the typed age? What’s going wrong? public class Pessoa{ private int idade; public Pessoa(int idadeInicial) {…
-
-1
votes1
answer171
viewsError converting value to Jtable
I have an error when passing formatted value to the JTable, if anyone can help, I really appreciate. This error only happens when I format the number, I wonder how I do to fix it. Code: private void…
-
-1
votes1
answer39
viewsFilter in consultation
modelo.setNumRows(0); Class.forName(Auxiliar.AcessoBanco.getDriver()); Connection con = DriverManager.getConnection(Auxiliar.AcessoBanco.getUrl(), Auxiliar.AcessoBanco.getUser(),…
-
-1
votes1
answer849
viewsAttempt to invoke virtual method on a null Object Reference
Error: 09-12 17:13:09.088 26022-26022/costamilam.guilherme.contatosempresariais E/AndroidRuntime: FATAL EXCEPTION: main Process: costamilam.guilherme.contatosempresariais, PID: 26022…
-
-1
votes1
answer85
viewsJtable search does not return as expected
I have a bug I don’t understand. The idea is simple, I should type a value in a field and it returns me in the table, this happens, but when I click on the value found in the search it selects me…
-
-1
votes2
answers349
viewsJava code help (Beginner)
I wrote this code in java to study. (I’m learning) but when I try to create a new error object. Class Empresa : class Empresa { String nome = ""; String cnpj = ""; int numeroDeFuncionario = 1;…
javaasked 7 years, 7 months ago Davi Mello 420 -
-1
votes1
answer119
viewsHow to get JSON values that Okhttp generated?
This is my code public void loginRequestAsync() { OkHttpClient client = new OkHttpClient(); HttpUrl.Builder urlBuilder = HttpUrl.parse("xxx.xxxx.xx.x.xx.xxx.x").newBuilder(); String url =…