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
answer80
viewsDate Conversion/Formatting Problems
I’m having trouble formatting a date for useful, I need to format a date that this Tue Nov 22 00:00:00 BRST 2017 (example) for date in format dd/MM/yyyy. I’ve been seeing some links, like: How to…
-
2
votes1
answer2487
viewsHow to make a method return a string in Java
I want to create a program that reads the name and age of a person and compares the ages and finally shows the name of the older person. My reasoning was to compare which is the highest and return…
-
2
votes2
answers114
viewsError while trying to compare date
I’m trying to create a validation, to know if the user is at least 12 years old. I tried to base myself on that question: Comparison between dates. However, I believe I’m comparing it wrong, since…
-
2
votes1
answer1274
viewsMethod that returns how many levels has a Binary Tree
I’m trying to implement a Binary Tree for the first time but I’m having difficulty in the method that returns the amount of levels present in the tree after filled. The method below can perfectly…
javaasked 7 years, 2 months ago A. Fernando 199 -
2
votes1
answer1063
viewsDoubt error "Unable to build Hibernate Sessionfactory" Java
I received the sources and after doing the server settings, database etc, I have this problem in the compilation. I would appreciate it if someone could indicate a direction in the solution.…
-
2
votes2
answers471
viewsQuestion using while
I am new in java and would like a help from you, my code is correct following the exercise I am doing, but I want to increment it using while to ask the user if he wants to repeat the process of the…
-
2
votes2
answers698
viewsHow to make Linearlayout stay at the bottom of the screen?
I’ve tried many things here to make my Linearlayout stand at the bottom of the screen but I can’t do that. I need to do this with Linear which has id= "underneath" Does anyone know? Follows my xml:…
-
2
votes2
answers115
viewsWhen adding system function does not compile
I have the following class: package br.com.xti.ouvidoria.helper; import java.util.Collection; /** * @author Samuel Correia Guimarães */ public class ValidacaoHelper { /** * @param obj * objeto a ser…
-
2
votes1
answer147
viewsProblem entering data with methods. Java/Mysql
I get the following error when I try to add a new data into a table in my database. I have a class whose name is Banco de Dados , another whose name is ShowMenu and another whose name is Principal.…
-
2
votes1
answer331
viewsHow to know if a Jdialog window is open or closed?
I was wondering, how can I know if a screen, in my case a JDialog is open. Is there any event or way to know this? Note: I will use this "information" as a parameter in a condition, for example, if…
-
2
votes2
answers504
viewsQuery with android sqlite java filter
public ArrayList<Contato> filtrar(String filtro) { ArrayList<Contato> contatoArray = new ArrayList<>(); //Consulta que traz todos dados de todas colunas Cursor cursor =…
-
2
votes1
answer53
viewsHow to specify the sequence of activities to be initiated?
Hello. I have a question. I have an APP in which 8 Activities, among them has a Splash Screen Activity that presents my logo and then enters my APP. The Splash Screen is set as default, but I need…
-
2
votes2
answers229
viewsDynamic SQL result sorting
First good afternoon, I work specifically with Java in the Back-end using Webservices Rest and Postgresql, after some professional enhancements I was instructed to pass ordering and pagination of my…
-
2
votes1
answer794
viewsHibernate does not find mysql JDBC "Driver" class in Maven project
Hello guys I created a Maven project in eclipse (with WAR packaging) and imported the packages of models already mapped from another project, soon after I created a class to "load" a persistence…
-
2
votes2
answers614
viewsToggle the colors of a column using the java library - apache poi
I am using java with apache poi library to create an excel spreadsheet. I need to keep alternating colors, 1st column (which is department), between yellow and blue, when the data are different as…
-
2
votes2
answers366
viewsProblems using Selectonemenu primefaces
I have a problem to update the data of a Selectonemenu in the primefaces, as suggested by the code below, I have a button that when clicked, brings data of a Webservice and stores in a variable of…
-
2
votes3
answers166
viewsGet String Snippet with Regular Expression
In the code there is a string that contains HTML. Inside this HTML there is a embed of a Youtube video: <embed type="application/x-shockwave-flash"…
javaasked 7 years, 2 months ago Filipe Moraes 8,737 -
2
votes1
answer451
viewsJava proxy configuration on Linux system
I have proxy configuration on my network, and to run java I need to set the proxy properties on it,. In windows is not necessary, it is working perfectly. "Exception in thread "main"…
-
2
votes1
answer3602
viewsElectronic voting systems in Java
I am making an electronic ballot box that register, list and the user can vote for the candidate, I can already register and list candidates, but how do I always count +1 in an attribute votes of…
-
2
votes1
answer48
viewsNoclassdeffounderror after removing external API (Youtube)
I’m developing a cool project and I came across a difficulty that I couldn’t get out yesterday, the project stopped recognizing all api’s, butterknife, Youtube, everything... Follow the error:…
-
2
votes1
answer43
viewsHow to create a date search method?
I can in no way create a date search method that works. I’ve already been able to register the date and other attributes as well. I have already managed to list all attributes and also search all…
-
2
votes1
answer370
viewsPick up a XML list in JAVA
I’m trying to get an XML list but I can’t put it in the variable. Main class: import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL;…
-
2
votes1
answer137
viewsProblems with improper access to urls in the application with Spring Security
I have a page, which uses Thymeleaf to update a user’s profile and on this page there are two buttons that allow you to update the profile and the other button allows you to remove the profile of…
-
2
votes1
answer84
viewsProblem with AVL tree vector
Good afternoon! I am making a hash table and for this I am trying to create an AVL tree vector. The problem is that when I try to insert a value in any tree of this vector is giving the exception…
-
2
votes0
answers48
viewsDeserialization of the wrong json on the date of the object on the java server
I have a User object and it contains the dataDeascimento attribute, I pass the user object to the server, the date I provide in the following format 2017-12-31, but the server changes to 2017-12-30,…
-
2
votes1
answer2003
viewsLoop "for" counted odd number, even and average
I need to make a code that: List a number of numbers Inform if they are divisible by 3 and 5 Whether they are even or odd And then take the separate average of each (average of odd and average of…
-
2
votes1
answer56
viewsShared Preferences Android Stidop
I had to watch a tuturial on youtube and copied this code to save and delete entered values, my doubt is that always appears that "0" as below and I would like to know how I can takeit without…
-
2
votes1
answer96
viewsResult of the GET method brings all database relations and subrelations
I have an application where I have a listing screen I’m doing a GET method on my Spring Boot API Controller class @RequestMapping(method = RequestMethod.GET, value = "/distritos", produces =…
-
2
votes1
answer395
viewsHow to validate a text field with Inputverifier?
Usually when I need to validate a text field without using action events, I use focus events such as those available from the interface FocusListener. In this example, I check if the field was…
-
2
votes1
answer107
viewsUsing the Java Synchronized
I was doing some exercises in Java, and I came across this code below in a question, stating that "The implementation of the method doLog class Escritor must be qualified as synchronized". How do I…
-
2
votes1
answer673
viewsSet timeout on thread execution and save return value
Hello, I have a web service, with backend in java 7. At some point, the backend makes a broadcast RPC call to N servers that are listening. Except that there is no predefined timeout in the call, I…
-
2
votes3
answers121
viewsInteresting question about inheritance and polymorphism
I found this question of an open competition interesting: Class A public class ClasseA { public int metodoX(){ return 10 } public int metodoX(int n){ return metodoX() + n } } Class B public class…
-
2
votes0
answers237
viewsProblem in left Join JPA - JPQL
Exception in thread "main" javax.persistence.Entitynotfoundexception: Unable to find CNPJ with id 00001388000307 Reading the documentation, I saw that this Exception is released when it tries to…
-
2
votes2
answers1029
viewsMethod to change CSS subclass (choicebox item text color)
I have a Choice-box. In my Choice-box there is a list of colors to be selected by the user through the interface. Every time the user selects a color, the background of that same Color Box gets the…
-
2
votes0
answers63
viewsIs it possible to save a file to "Downloads" using Totalcross?
To put it in context.. Initially I was trying to implement the opening of a PDF using Totalcross as can be seen in this issue: How to open a PDF using Totalcross? However, there is no solution to…
-
2
votes1
answer680
viewsGson Library Changing useful. Date
When using the library GSON for the manipulation of JSON, I realized that by doing the parsers the date is being changed, it’s tiny, but it’s enough to break my unit test with JUnit. Follow a sketch…
-
2
votes2
answers1184
viewsproblem with daylight saving time and java applications on Ubuntu server 16.04
This weekend we had the change to summer time here in my region, I have some machines running Ubuntu server 16.04 with java applications. All of them with JBOSS, POSTGRES for one application and…
-
2
votes1
answer2185
viewsConvert Roman numbers to Java
I made a program that converts whole numbers to Roman numbers in Java, but the program does not run. What can it be? Follows the code: import java.util.Scanner; public class Teste { public static…
-
2
votes1
answer499
viewsHow do I define the size and place of components?
I created this code in java to train a little and learn but I can not set the place where the JComboBox and the JTextField will appear and the size of them as I do? I want to leave them in the…
-
2
votes1
answer941
viewsHow can I divide the plots, adding only exact values for each plot, and a plot will be with an extra value?
Example: The division of 100 (input value) by 3 (number of plots) is equal to 33.33, where 3 * 33.33 = 99.99. Being that the right is a portion with the value 33.34. Java code public void parcelar()…
-
2
votes2
answers116
viewsAPI method searches for information but does not appear in front-end
I have a method of my API that does a database search @RequestMapping(method = RequestMethod.GET, value = "/entidadesUsuarioPermissao/{id}", produces = MediaType.APPLICATION_JSON_VALUE) public…
-
2
votes1
answer57
viewsonSpinWait Java 9
I am porting a Java 8 application to 9, I have some processes that use the concept of Watchdog, who use something similar to: public synchronized void run() { until = System.currentTimeMillis() +…
-
2
votes2
answers261
viewsWarning:(40, 5) Do not place Android context classes in Static Fields; this is a memory Leak (and also breaks Instant Run)
I’m coming across this warning from Android Studio. Warning:(40, 5) Do not place Android context classes in Static Fields; this is a memory Leak (and also breaks Instant Run) I have a button that…
-
2
votes0
answers136
viewsDialog Progress Opaque White Background
I’ve been trying for a few days to reach a transparent Progress dialog with an opaque white background equal to the images below but only get to black background opaque in the android pattern I’ve…
-
2
votes0
answers839
viewsSpring Boot connectable in Microsoft Sql Server database
I’m trying to connect in Sql Server 2008 database, but this giving this error: com.microsoft.sqlserver.jdbc.Sqlserverexception: Connection to ERSERVER host failed, instance named sqlern_desenv.…
-
2
votes2
answers2051
viewsMatrix multiplication in Java
I need to make two matrices multiply, but I’m wrong when it comes to multiplying. int ma[][] = new int [3][2]; int mb[][] = new int [2][2]; int mab[][] = new int [3][2]; for (int i = 0; i <…
-
2
votes0
answers638
views(Java) Reading the Serial Port with the Jssc library
I have a java app that reads on the serial port with 7 data from a rotational sensor coming from the Arduino, via jssc. The code works, but the data is not formatted. I read 4 in 4 bytes, but…
-
2
votes1
answer956
viewsCreating a conversion table from Fahrenheit to Celsius degrees
Write a program that given two temperatures in Fahrenheit degrees (integer values) produces a table with all values in this interval of half degree Fahrenheit. For example, the execution of the…
-
2
votes2
answers79
views -
2
votes0
answers84
viewsPick time and notify user
I created this code in Android Studio to inform the hours of the buses here in my city but I wanted the app to inform what the next bus the person could get as soon as she accessed the list view and…