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
-
2
votes1
answer1142
viewsWhat is the function to see the tank distance to the wall in the robocode?
I’m trying to implement on robocode sourcecode (for those who don’t know, follow the link: http://robocode.sourceforge.net/) a means to make the tank continue walking and, from a certain distance…
-
2
votes1
answer101
viewsMethod does not accept passing from null to parameter
I have the following method: public String insereRegistro(int tipo, String data, String horario, String historico, int veiculo, double km, int cliente, int solicitante, String finalizado) { ... }…
-
2
votes1
answer507
viewsJbutton shoot two different events?
I have a program that simulates a game of dice, where I have two "dice" that, when the sum of the two gives 7, the user is winner, if not, he loses. Well, I made a simple interface on swing, where I…
-
2
votes1
answer65
viewserror in comparison using substring
maquina += numeroale.nextInt(4); maquina += numeroale.nextInt(4); //vez da mqauina for (int i = 0; i < maquina.length(); i++) { System.out.println("valor atual"+maquina.substring(i,1));…
-
2
votes1
answer134
viewsDifference in Java casting
What is the difference between the 2 codes below? first int x = 10; float i = (float) x; 2nd int x = 10; float i = Float.parseFloat(x);…
-
2
votes1
answer239
viewsException in thread "main" java.lang.Nullpointerexception: Calculator
I started studying Object Orientation and decided to make a simple calculator program. At the moment I just made the sum to see if the way I was doing is right. Follows the code: package…
-
2
votes0
answers280
viewsblock second tab of the same user session with JSF
I have a problem. How do I not allow two tabs to access the same session, using JSF. I have a web system where every user has their profile. And the profile is used to generate custom forms. After…
-
2
votes1
answer663
viewsUser has exceeded the 'max_user_connections' Resource (Current value: 4)
I have a problem regarding open connections in the database, where error is occurring if the application tries to create more connections than the limit. Assuming the application creates and closes…
-
2
votes2
answers393
viewsCompressing a string to upload into a field of the JSON object
Hello, I am developing a java API, which returns a json object. One of the final json fields is long text, of unknown dimension. Text may or may not contain special characters. I am sending the raw…
-
2
votes1
answer2606
viewsHow to use java LOGGER
I set up the Logger in my main class. public static final Logger LOGGER = Logger.getLogger(DashBoard.class.getName()); and I’m using it this way: LOGGER.log(Level.SEVERE, "Error occur in…
-
2
votes1
answer550
viewsWildfly 11 does not recognize Mysql driver when deploying
I set up my Java Web project to use JTA when performing transactions with the Database. My project has 4 Maven modules, one is unique to model classes and the persistence layer. When I compile in…
-
2
votes2
answers300
viewsError formatting date:
Hello, I’m formatting the date with the following code: Date data = null; SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { data =…
-
2
votes1
answer667
viewsFind all occurrences of a pattern in a String
I need to use regular expressions to find patterns in a text. It would be better for me if there was a method like search() Python, which returns an array with all occurrences of this pattern. There…
-
2
votes2
answers410
viewsAndroid - Transfer Data and Change Fragment by Click
Hi guys. I need help to transfer from Fragment when I click my button inside a Listview. Currently I have a Mainactivity (extends Appcompatactivity) to manage the Fragments. Below are some images of…
-
2
votes2
answers316
viewsInsert record into bank inside a for using Hibernate
I need help, I’m trying to create a fixed expense launch. I have to insert for example 12 records in the database, through a loop inside the for. To enter the data I am using Hibernate, however it…
-
2
votes1
answer568
viewsWeb Crawler (Spider) with ajax in JSF using Node.js or Jsoup api in java
I have the task of creating an interface optimized for touch monitor, taking data from a website (http://www.consultas.der.mg.gov.br/grgx/sgtm/consulta_linha.xhtml). This site gives a listing of bus…
-
2
votes2
answers2215
viewsRegular expression to find numbers in between words
Currently I am developing a project of which I am using regular expressions to find certain patterns, however there is a String specific and need to extract two numbers from this, the expression is…
-
2
votes3
answers438
viewsClose in Transaction with Ibernate
Hello, I need some help. I’m trying to make a transaction on Ibernate. The problem is that by giving a close, the data are modified in the database, but this occurs WARN: WARN…
-
2
votes1
answer1018
views"break" inside a chained if-lse
I’m new here and I have a very simple question: is there some kind of "break" so that it can be used within a if-else chained? if (valor > getSaldo()) { System.out.println("Valor informado maior…
-
2
votes1
answer182
viewsHow to pass a class with Bigdecimal and Date attribute through intents(Bundle)?
I have a ArrayList<MinhaClasse> with Bigdecimal attribute and I am going through Intent from one activity to another. The problem is that the Bigdecimal attribute passes with null value. Can’t…
-
2
votes1
answer1433
viewsDoubt with Preparedstatement with INNER JOIN in Java
I have a question about using Preparedstatement with INNER JOIN, here’s my code: public List<Emprestimo> pesquisar() throws SQLException { List<Emprestimo> listaEmprestimo = new…
javaasked 8 years, 5 months ago Vinícius Novelli 173 -
2
votes1
answer305
viewsQuestions about the Graphics and Graphics2d classes in Java
I am having many doubts regarding the graphic libraries of Java, which are the following: What is the difference between overwriting the method paint(Graphics) or the method…
-
2
votes1
answer32
viewsDoubt regarding the Dysplasia() and Repaint() methods
What is the function of the methods .dispose() and repaint() using Graphics in Java?
-
2
votes0
answers41
viewsExtract content from a JSP page to a String in a Java class or Servlet
Good afternoon, I would like to check if anyone knows how to extract content from a JSP page to a String. Example: I have a JSP page with HTML content, I want to pass this HTML content to a String…
-
2
votes3
answers1139
viewsRetrieve/locate object in arraylist
I am making a small CRUD with the theme saving for study purposes. I created 3 classes: Save, Accounts and Canvas (UI Swing). On the screen I register an account with the attributes name, agency,…
-
2
votes2
answers823
viewsSwap Long for Biginteger or Bigdecimal?
I am trying to read from the keyboard a very large integer number, I saw that there are the type Biginteger or Bigdecimal, I do not know if they are bigger than the Long. wanted to read from the…
-
2
votes1
answer2017
viewsHow to store data in RAM and make it available to any module or class in my application?
There are several ways to store the data of a particular application and some of them are: Disk Storage (HD). It can be a text file, XML, or a database file of some DBMS. Cloud Storage (Cloud). It…
-
2
votes3
answers654
viewsHow to separate a number into two
How could I separate a number with decimals into two other numbers? The idea is as follows: when entering a number in the terminal, for example 125.69, when passing the number to the code pull the…
javaasked 6 years, 8 months ago Maicom Rodeghiero 72 -
2
votes1
answer108
viewsConvert tuples from different databases into a particular Java object
Well folks, I don’t know if the title of my question is quite correct, if not, someone please edit. I’ll explain my problem. I developed a tool that checks conflicts between access control policies…
-
2
votes1
answer80
viewsJboss Forge x Spring Boot
What difference between Jboss Forge x Spring Boot? When using one or the other? Is there any "Tomcat Forge" for example? Or are they different things?
-
2
votes1
answer1008
viewsError inflating class android.support.design.widget.Navigationview
It is working correctly on most devices, however on other devices the following error is occurring: android.view.Inflateexception: Binary XML file line #16: Error inflating class…
java android xml android-layout navigation-drawerasked 8 years, 5 months ago Giancarlo Abel Giulian 3,999 -
2
votes1
answer61
viewsTake all elements that meet a condition
I have some Vector: public static Vector<Integer> id = new Vector<Integer>(); public static Vector<String> nome = new Vector<String>(); public static Vector<String>…
-
2
votes1
answer817
viewsSave Rest entity using @oneToMany
I have the following entities generated by jHipster using java with oneToMany relationship: Product @Entity @Table(name = "produto") public class Produto implements Serializable { private static…
-
2
votes1
answer909
viewsI can’t do a click counter on a Jbutton
I am developing a "game" where there is a button on the screen and the player has to click several times on the button to make money. For that, I’m doing a sort of click counter, where the variable…
-
2
votes2
answers711
viewsUsing Maven or Spring Boot?
In my researches I could understand that there is how to perform application Profiling (e.g. homologation and production) in two ways, via Maven and spring-boot. The big question is that I have…
-
2
votes0
answers38
viewsVector fill problem with typed text reading
I’m doing a little job, which consists in registering teams and matches of a football championship. When compiling and executing the code, it works, but in the part where I will register, it jumps…
-
2
votes1
answer139
viewsJson - JAVA (Eclipse)
How do I read a JSON (jsonl) file through the eclipse in java? Need some package?
-
2
votes1
answer147
viewsWhere to store binary files in Junit Unit tests with Maven?
I have the following directory structure for the Unit tests Resource folder: src/test/resources/*.files So that I can read binary files (like a PDF for example) to complete a Unit test, I am…
-
2
votes1
answer43
viewsGet name resolution time on HTTP request
Long live, Is it possible to obtain separate name resolution time from access time? The code I have is: HttpURLConnection connection; try { URL endereco = new URL(url); connection =…
-
2
votes0
answers264
viewsInclude and remove elements from a Json with lib Gson (Java)
I am using the Gson library in Java, I have the following structure in a json file: {"idAluno":4, "nomeAluno":"Teste da Silva", "listaDeTurmas":[1,2,4]} Is it possible, with this library, to change…
-
2
votes0
answers133
viewsJava robot and program blocking clicks from it
I’m making a very simple robot for a game. my code: if(e.getKeyChar() == 'e'){ Point p = new Point(); p = MouseInfo.getPointerInfo().getLocation(); textField1.setText(""+p.x);…
javaasked 8 years, 5 months ago Gustavo Pinoti 31 -
2
votes1
answer804
viewsDelete files created before 10 days ago from current date
I am trying to automate the deletion of some backup files that a small application I made in swing creates, which over time, accumulates, occupying too much space in the network directory, which…
-
2
votes1
answer940
viewsFind and open file . txt, add info and save to java
I have a little project of a system for clinics where the receptionist makes the register of the patient by placing his personal information and saving it in a txt file. Then when the doctor…
javaasked 8 years, 5 months ago Carlos Diego 683 -
2
votes1
answer581
viewsRead all txt files in a folder
I am trying to list in my project all the files that I saved previously in the program inside the query folder, however it does not only show the files, it also shows their respective paths. How do…
javaasked 8 years, 5 months ago Carlos Diego 683 -
2
votes1
answer74
viewsRetrieve gateway from the network?
Does anyone know or knows any way to find the IP address of gateway network ? The local ip I know I can recover with the class InetAddress: InetAddress.getLocalHost().getHostAddress();…
-
2
votes1
answer244
viewsError trying to swap Jframe icon
I am using Netbeans, but I want to change the default icon of my application. But, I came across this error. Follows the code: import java.awt.Toolkit; /** * * @author renato.lazaro */ public class…
-
2
votes2
answers451
viewsHow do I change the increment of a button by another button?
I have a button that adds a variable: x + 1, and every time I click on that button, the variable will increase 1 unit. But how do I program a button to change the function of button 1, so instead of…
-
2
votes1
answer581
viewsAction <p:commandButton does not call Method in Managedbean
I am trying to call a method in my Managedbean, however the form is not submitted. Detail. I have a dialog that inside it I have some includes of other xhtml files, follows as this up to the moment…
-
2
votes1
answer1245
viewsHow to handle Null records? In the database or app? (java & Mysql)
I am integrating a legacy database (Mysql) with a new module (Java - this problem object is a bean) that I am developing. I have a method that makes a select and returns some results that eventually…
-
2
votes1
answer341
viewsWorking with list and objects in Java
I have a java class called Library. with attributes: name, city, number of employees: public class Biblioteca{ String nome; String cidade; int qtdFuncionarios; //depois getters e setters e…
javaasked 8 years, 5 months ago PHP developer 205