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
answer24
viewsError in using Mockito. Actually, there Were zero interactions with this mock
I am trying to do a check but for some reason the test is not passing. I have no idea why. Follow the error shown: Actually, there Were zero interactions with this mock. Follows the code: public…
-
1
votes0
answers82
viewsHow to set up CORS in Springboot?
Recently I decided to try developing in java with Spring boot. I’m not very experienced in this framework. I tried to make a complete application, with back-end with this technology and front-end…
-
1
votes1
answer27
viewsChanging the value of an arraylist
I have a problem in CASE 4 of my code, I want to change the price of the movie by calling the set, But it doesn’t change. I think it’s a logic problem, I’m a beginner. public static void…
-
1
votes1
answer170
viewsWhat is the best way to edit an entity with Spring?
In my Controller I have the following mapping to display a person’s registration edit form: @GetMapping("/mostraEmpresaEdicao/{idpessoa}") public ModelAndView…
-
1
votes1
answer61
viewsHow do I check if my input is number or text?
I wonder how I can check the kind of value that goes into my Scanner, to return to the user that that entry only receives a number and that he has typed a text or character. public class…
-
1
votes1
answer237
viewsError "Exception in thread "main" java.lang.Arithmeticexception: / by zero" in java
I’m trying to solve an exercise, but it keeps going wrong. I wonder if someone could help me? public class mod_IV_ex_1 { static int fatorial(int numero){ int fatorial = 0; if (numero == 0) {…
-
1
votes2
answers81
viewsHow do I replace characters from a string, right to left, cumulatively?
I’m trying to write a function that gets a String and replaces its characters from right to left, for zero. I would also like to do this cumulatively and save the changes. For example: String teste…
-
1
votes1
answer103
viewsProblem with JPA Hibernate
I have a problem in a system that I am developing using springboot together with JPA Hibernate. I’m not so experienced using them, so forgive me in advance. Let’s get to the problem: I have 2 tables…
-
1
votes1
answer182
viewsAlgorithm for transiting in the Cartesian plane
I’m trying to codify the solution to the classic problem of walking around the Cartesian plane, starting from the origin, based on a user-given input string. Being: And: anti-clockwise rotation of…
-
1
votes1
answer95
viewsVector help in Java
Guys, I wonder if you have any function ready in Java or some easy way to make the name of the students with the highest grades appear together, because you’re always getting the last student with…
javaasked 3 years, 12 months ago mathelzreis 21 -
1
votes1
answer197
viewsVisualg does not recognize the "fimse"
My algorithm is this below: Question. Request the wedding year, the current year and write the following messages, for the following cases: 25 years - "Silver Wedding"; 50 years - "Golden Wedding"…
-
1
votes0
answers226
viewsCucumber-Enconding does not accept accented variable
in my software test done on Cucumber in a specific scenario I assign a string to a variable: Scenario Part: "Then the system displays the message "Invalid User or Password!" The string "Invalid User…
-
1
votes1
answer53
viewsHow to access mother class fields through inheritance?
Simplifying what I mean, suppose I have a Mother class: public class Mãe { private String nome; // Declarando o campo privado nome public Mãe(String _nome) { nome = _nome; // Definindo o campo nome…
-
1
votes2
answers215
viewsHow to map class fields with names other than database columns?
I’m using IDE Intellij. I have the following model: @Entity(name = "carro") @Data public class Carro { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String nome;…
-
1
votes0
answers19
viewsError with socket tcp on android
I’m having a null error, I no longer know what I do, I’m using socket tcp in java in android studio, I already got the permission in the manifest, before I gave wrong permission denied, now the null…
-
1
votes1
answer67
viewsThe Toolbar is not appearing
I’m making an app for my tcc and I decided to put a side menu in the app, the menu works, but where the Toolbar appears only a black belt without icon and I put a burger menu icon. I am using…
-
1
votes0
answers12
viewsCompilation error, Exception in thread "main" java.lang.Arrayindexoutofboundsexception: 0
Compiler points out the following error: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 Just after points to the if line public class Pilha extends Lista { public Pilha(int…
-
1
votes1
answer53
viewsRegister authenticated users with Facebook in Firebase Database
Good night! Guys, I’m using Facebook login in my app and would like to register the user information in the database or firestore Realtime, as the name and email for example, I’ve recovered the…
-
1
votes0
answers19
viewsPrimefaces Tabview Component Disappears
Hello, I am testing the Tabview component with mandatory fields included in each tab. I use ajax with update="@form" to update the component, but when I click on another tab, the Tabview bar simply…
-
1
votes1
answer52
viewsHow to get around the use of reserved database words with Hibernate?
I am learning to work with REST API in Java using spring with Hibernate and I have the following problem. My entity has the name user which is a reserved word in the database I’m using(postgres), so…
-
1
votes1
answer100
viewsRecursive Binary Search does not find the element at the last vector position
I made a recursive binary search code in Java. It finds the positions correctly, except when the searched element occupies the last position of the vector. I don’t know how to fix this. public…
-
1
votes0
answers35
viewsUsing Netbeans to Access BD Posgresql - jdbc. Drivers
I made the connection in the database using netbeans but is not finding the DRIVE, apparently everything is correct, but always returns the error: No suitable driver found for…
-
1
votes0
answers11
viewsChanging Widht and Hight of a Java text using the Graphics Class
Hello, follow my question.: As the image below would like to play something like this in Java using the Graphics Class I want to be able to scale a text with the Drawstring method, I took a look at…
-
1
votes0
answers27
viewsDifficult to understand how eventlisteners work in Java?
Greetings dear fellow programmers Are you all right? I hope so I’m doing this publication because I’m having a lot of difficulty to understand a specific parameter of the listeners of Android…
-
1
votes0
answers43
viewsMake Crosstab columns have a dynamic width | Jasperreports
I’m working with DynamicJasper to generate a report with a Crosstab with dynamic columns, but I’m having a problem, the table you’re generating is exceeding the page width limit and some columns are…
-
1
votes1
answer50
viewsVolley Android - GET to return list of videos from a playlist - JAVA
Hello, I’m using the android library Volley to make a GET call (https) to return to me the Json of the videos of a specific playlist. Basically my current GET request is this: String url…
-
1
votes2
answers161
viewsRecursiveness in Java
I’m trying to create a recursive method, which shows me all the cost centers children who do not have other children, for example: If the father is the cost center 1, will return me the 3, 4 and 5.…
-
1
votes0
answers17
viewsError testing data source SQL Server on Websphere 8.5 server with java 8 gives the following error:
Error testing connection of data source SQL Server on Websphere 8.5 server with java 8 gives the following error: The driver could not Establish a Secure Connection to SQL Server by using Secure…
-
1
votes0
answers145
viewsEdit line in a file . class and recompile
I have a file called WEB.class that I imported from a.WAR file where I have the strings to connect to our database with the following code: @Produces({"application/json"}) @GET…
javaasked 3 years, 10 months ago user2993552 11 -
1
votes1
answer31
viewsProblems with the Bufferstrategy
I am recreating a code from scratch, but when creating a Bufferstrategy to draw on the screen I come across the following error in the console "Exception in thread "Thread-0"…
-
1
votes0
answers106
viewsMethod in p:commandButton is not called
In my view you have p:commandButton with a method that adds an item to a p:datatable. By clicking the button to call the method to add the first item, it is correctly added to the datatable, but by…
-
1
votes1
answer99
viewsJava: separate row into columns by character position
Hello, I turned the internet upside down trying to solve this problem. I have a text that in this format: 012016010402AAPL34 010APPLE DRN R$…
-
1
votes1
answer93
viewsOkhttp on Android connects to my websocket server but does not reflect outgoing messages
Following this documentation https://spring.io/guides/gs/messaging-stomp-websocket/ created a small spring project capable of sending messages in real time using websockets, the web part stays this…
-
1
votes2
answers32
viewsI need to separate a String message in 6 Textviews
I’m making an app with bluetooth connection and it captures the messages or data that are sent by the Internet via Bluetooth, I’m sending these messages via Bluetooth, each call sends a data and…
-
1
votes1
answer33
viewsI’m trying to open a file with Jfilechooser and read with Bufferedreader but is only reading the last line
here is the code import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import…
-
1
votes0
answers41
viewsError while booting Spring Boot
I’m studying Systems Development and Analysis, and before in programming classes I was learning to use Java with Spring Boot. I use Netbeans 8.2 with JDK 8u261 and I have two Hds, I try to save all…
-
1
votes1
answer498
viewsApp does not share using Whatsapp appears: "Failed to share. Pro please try again."
When I choose Whatsapp to share appears a message: "Failed to share. Please try again." My code is like this: compartilhar.setOnClickListener(new View.OnClickListener() { @Override public void…
-
1
votes2
answers123
viewsCheck if Java List has duplicate object attributes
I need help creating a logic that checks whether certain attributes of an object, stored in a List<Object>, there are more than two times. I’ve tried using the Set<E> to check whether it…
-
1
votes0
answers54
viewsServlet mapping via annotation @Webservlet is not working
I’m a beginner in Javaweb development. I’m using Java version 11 and Tomcat version 9.0. When using the annotation @WebServlet(urlPatterns) in the classes OiMundoServlet.java and…
-
1
votes0
answers37
viewsAPI GET Authentication Method
good night, I’m having trouble getting a GET Method with Authentication to work I have read the Documentation and installed the SDK in the Intellij IDEA of an Exchange API and am having difficulty…
-
1
votes0
answers16
viewsError with Bufferstrategy (Java)
Well, I’m new to Java and I was studying rendering and buffers until I came across the following mistake: Exception in thread "Thread-1" java.lang.IllegalStateException: Component must have a valid…
javaasked 3 years, 8 months ago Ramsés De Oliveira 11 -
1
votes1
answer202
viewsPrime number JAVA
I have to create an algorithm in java to detect the prime numbers in a range that the user choose for example "the existing numbers from 1 to 50" the result is coming out correct in the eclipse…
javaasked 3 years, 8 months ago JOÃO SOUSA 21 -
1
votes0
answers20
viewsHow to save spinner items in firebase
I’m a beginner in android studio and I stuck in a part, I already looked here in the stack I saw some possible solutions but they didn’t work for me, I don’t know if it’s because of my code, come…
-
1
votes0
answers22
viewsMessaging Cloug Firebase sends only once
Hi. I have an Android app that uses Cloud Messages, however, I noticed that I have some APP’s that the message does not arrive. For example, I have active X Apps in the playstore, but Firebase shows…
java android android-studio firebase firebase-cloud-messagingasked 3 years, 8 months ago Joel Nascimento 21 -
1
votes0
answers21
viewsCordova Music Controls Plugin, how to make it work?
I’ve done the plugin installation normally, tbm this is all ok with deploy and the app is running normal, but ñ know how to run the plugin to put the audio control in the notification bar, there are…
-
1
votes0
answers32
viewsError in performing criteria with filter on object belonging to Composite ID
An error occurs when I try to search the Car domain class by applying a filter on the Mark which is a FK and is part of the Composite ID. class Carro implements Serializable { Marca marca LocalDate…
-
1
votes1
answer20
viewsReceiving system variable and sending to dropdown
good afternoon. I’m still in the way of programming with html and javascript. I’ve done a lot of research on what I want here. Some have come close, but not to the point of what I intend. The…
-
1
votes1
answer30
viewsI am trying to move a file that is inside an Array using renameTo
Hi, I’m new to java and I’m having a hard time using "renameTo". and in this activity I have to move files do not meet the following requirements Is not empty; Each row of the file has the exact…
-
1
votes2
answers292
viewsjava.util.Illegalformatconversionexception: d != java.lang.Integer
What’s going on here? I don’t think I can read the documentation from String format.(). For me this date/time conversion %td When receiving an integer within the interval of the day of the month it…
-
1
votes1
answer46
viewsHow to change the result of requesting a Rest API with Spring?
Eai guys, all right? I started studying Spring recently on my own and am trying to create a Rest API for enrolling students and exams at a school. I have the following problem: When I make a GET…