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
-
0
votes1
answer304
viewsWhich method to use Sharedpreferences best?
I have an application with a webview in which a token returns when the user logs in. I need to save the user information to perform the auto-login the next time he logs in, I intend to do so using…
-
0
votes0
answers34
viewsLocal Notification error by clicking again instates the same app
Next, I created a radio app and when the app opens has the splash and starts playing. It has a program scheduling feature. If I have the app open and get notification, it keeps playing the radio,…
-
0
votes0
answers73
viewsWildfly changes the GMT
Good afternoon. I’m having a problem with a back-end Api running on a Wildfly server ,I have a mobile app that posts this api in a java.util.Date variable, when I post to the server it adds 2 hrs…
-
0
votes0
answers51
viewsParse relational query in a single Httpget call
good morning. This question is for the Android environment. I use ADT. I need to implement in Parse a Car table and a Manufacturer table. Car has the model and manufacturer fields. The Manufacturer…
-
0
votes1
answer3898
viewsObject References an Unsaved Transient instance - save the Transient instance before Flushing
I have the following problem I have three tables one with the name User with the following properties: Id, User, Username and Password Person with the following properties Id, Name Functionary with…
-
0
votes0
answers211
viewsHow can I make Cardview dynamic-sized?
I got a little problem... I have several Cardsview and their size is static I would like to know how to make this size adaptable to what is on cardView. Because in a Cardview I have a list that…
-
0
votes1
answer118
viewsHibernate - Set foreign key object without seeking object. Direct by Id
Someone knows if it is possible for me to set an object that is a foreign key if I have to look for it. That is, just by setting the direct id? Example: low.setIdEmpress(daoEmpresa.buscaPorId(new…
-
0
votes1
answer686
viewsHow to return status code from Java Resteasy request
It’s quite intuitive to make a return of the API with an object or something like that, only you would like to make the return of an object along with the status code of the request. @Override @GET…
-
0
votes1
answer68
viewsCursor count returns more values but only adds one item in the list
I am consulting a table of Clients, I am selecting all test affine, but what is happening is that when playing the query on the cursor and giving a getCount it returns 4 as expected, but when giving…
-
0
votes1
answer688
viewsNavigation to pages in subfolders in JSF 2 does not work
I have the following problem: I have a hierarchy of folders where I separate my web pages from the project: Web |- Acoes | |- usuariosAcoes.xhtml | |- cadastrarAcao.xhtml |- usuarios | |-…
-
0
votes1
answer52
viewsInvalid "required" attribute
I took a project and the same is showing compilation error because it is not recognizing the attribute "required" in the excerpt below: @XmlElementRef(name = "Nome", namespace =…
-
0
votes1
answer303
viewsPerformance when generating a JSF table
I’m having a question of how to improve perfomance when generating a table on a page using components JSF and Primefaces. I am generating a table, after making an SQL query and mapping the object…
-
0
votes1
answer161
viewsRendered Does not work in datatable
Good afternoon. I have a simple problem. However, I am struggling to solve. I have these 2 methods to control my Rendered do dataTable: // Filtra o simulado.. @Transactional public void…
-
0
votes0
answers57
viewscolor a datatable using date
I’m just testing, I want to leave the source red if the date is less than or equal to today but nothing is happening tried with '2017-02-21' '21/02/2017' and does not work my css: .vermelho { color:…
-
0
votes2
answers208
viewsWhen no file is found, you should skip to the next step (Spring Batch)
I’m using Spring Batch. In my Job, I have several steps, and they all read from a file. csv. The problem is as follows, there will be times when the file . csv will not be in the available location…
-
0
votes1
answer46
viewsJava: Sending messages over the network repeatedly in another thread?
This is my problem: I need a message to be sent by a socket repeatedly, to do this, I created another Thread, so that the application would not be locked, so: new Thread(new Runnable(){ public void…
-
0
votes1
answer422
viewsColorize jTable lines ready
I have a code and I need to make some improvements, but I’m not able to insert them properly, I’m a beginner and I have some difficulties. The software has: a Beansclient class with the get and set;…
-
0
votes1
answer197
viewsJava - Canvas flashes when redesigning the screen
I’m making a graphical application with the class Component, but every time I delete the canvas to draw a new frame, Canvas flashes! The clearBackground function: public void clearBackground() {…
-
0
votes1
answer56
viewsError printing a single variable
I am unable to print an ultra simple code in Java. It shows the following error: Exception in thread "main" java.lang.Error: Unresolved Compilation problem: Cannot make a Static Reference to the…
-
0
votes1
answer111
viewsProblem using Gson in Wildfly
I am trying to use GSON in a Maven EJB project but gives the following error: java.lang.NoClassDefFoundError: com/google/gson/Gson When I test in class main without uploading the server to lib works…
-
0
votes1
answer67
viewsWhat is this about Stringbuffer being synchronized ? What is the advantage of Stringbuilder?
I know the difference between stringBuffer and stringbuilder is that one is synchronized and one is not, and that both represent strings that can be changed, but what synchronized means in practice?…
javaasked 7 years, 7 months ago jorge saraiva 478 -
0
votes1
answer32
viewsTo use Hibernatestatistics is required to create a Hibernate.cfg.xml?
I found nonsense, since usually the settings of Hibernate are allocated in the xml persistence. Can you recover the sessionfactory only using the settings of Hibernate allocated in persistence.xml ?…
-
0
votes2
answers283
viewsPlay Audioclip with . wav in another JAVA package
I use this code to play sounds in my application, but it only plays the audio if it is in the project folder, and not within a package. And if I export my project by creating a . jar it does not…
javaasked 7 years, 7 months ago Jessé Santos 3 -
0
votes2
answers9290
viewsHow to Check whether the date is valid or invalid?
I’m learning Java on my own and I came across an exercise that I don’t know where to start researching. I found something about datetime, Try, catch. But I couldn’t quite understand why the examples…
-
0
votes1
answer146
viewsInclude additional files to the DLL with JNA
am having a problem running a DLL in Java via JNA, the DLL searches for a file that is in the same folder called "propriedades.properties", this DLL works normally, but when using JNA it does not…
javaasked 8 years, 11 months ago Ricardo Rodrigues de Faria 983 -
0
votes1
answer105
viewsError while extracting fragmented Edittext data using a Helper class
I am trying to get the data of an Edittext that is in a fragment with the help of a Helper class, to later save in the database, but the following error is shown in the Androidstudio Bugger:…
-
0
votes0
answers95
viewsCalling a report with sub-report from a Managedbean
Someone has an example in Java of how to call from a Managedbean a report with sub-report? I already have the report with the sub-report working well in ireport,but when I try to call from the…
-
0
votes1
answer97
viewsError when using eclipse EE
I’m having trouble generating image in eclipse ee - it can’t open anything and keeps giving this error: GRAVE: Error Rendering View[/pages/produto.xhtml] java.io.IOException: javax.el.ELException:…
-
0
votes1
answer242
viewsHow to compare two List<Float> in Junit?
I need to compare two Lists, assertEquals(lista1, lista2); Assert.assertTrue(lista1.containsAll(lista2)); And the error the test shows is (index:22 size:22) java.lang.Indexoutofboundsexception Until…
-
0
votes1
answer53
viewsProblem to persist data in the database
follows the error I am taking at the time of persisting the data: 09:19:29,437 ERROR [io.undertow.request] (default task-7) UT005023: Exception handling request to /sic/usuario/salvar:…
-
0
votes1
answer267
viewsJava programming for cards
Hello, I have a KDE KT-2280 magnetic card reader and this reader is programmable. Only I don’t know how to program cards, because I’ve never touched on card programming. Is there a Java library for…
javaasked 7 years, 7 months ago Guilherme R 11 -
0
votes0
answers80
viewsBattery Power per App
I need to create something that measures the usage since the last full charge per app, I have no idea how to do... I searched and found nothing. All help is welcome, Thanks in advance.…
-
0
votes1
answer320
viewsMaven changing the faces-config.xml
I have an EJB project and my Maven keeps changing the faces-config.xml when I run "mvn install", Maven changes everything inside it leaving without the paths I specify, follows my "pom" file of the…
-
0
votes0
answers1290
viewsCreate/Edit file (txt) on Android
Hello... sorry if I posted in the wrong place or wrong way, because I’m new in the forum (although I always read it). Lollipop helped me a lot with the explanation: /a/48228/68502 But I have three…
-
0
votes3
answers192
viewsSwap String content for "$"
I have a string with a content and I need to make a replaceAll, but the text to be replaced contains a "$" dollar sign and this causes the error Illegal group reference. Example: String texto="teste…
-
0
votes0
answers212
viewsPDF Java memory overflow
Hello, good night. I’m having memory overflow problems in a java application when generating +/- 1000 PDF’s in a loop. In this application, to generate the PDF, a proprietary framework is used,…
-
0
votes1
answer76
viewsError: 'Operand type Clash: image is incompatible with Numeric'
When trying to save an object in the database, gives the following exception: org.hibernate.Exception.Dataexception: could not update. [...] Caused by: java.sql.Sqlexception: Operand type Clash:…
-
0
votes1
answer108
viewsHow to know when a Thread has been completed
I have the following implementation javascript on the call of a Thread. I would like to print in the log the moment Thread was finished. That’s possible? func4 = { run: function(){ atv4(); } }; r4 =…
-
0
votes0
answers62
viewsHow to instantiate the Firebase object to my URL, Help with the Error below
package br.com.netcriativa.umadeb.activity; import android.app.ProgressDialog; import android.content.Intent; import android.os.Bundle; import android.support.annotation.NonNull; import…
-
0
votes0
answers55
viewsHow to Refactor a Dependency Injection Program
Could someone explain me what the Dependency Injection Pattern is and how to refactor the following code? public class Motor{ ICombustivel combustível; public Motor(){ combustível = new Gasolina();…
-
0
votes0
answers81
viewsWhen and why should a static method be used?
I always had this question about the POO, I see many codes with Static methods and now starting in C# is no different. Being direct, when you should use this type of method, why use it and its main…
-
0
votes1
answer83
viewsWhy is it when I do two operations with integer numbers and save the result in a double it gives me a 0.0 return?
Example: double teste = 673/5455 * 100; System.out.println(teste); It prints 0.0 and this is not the result of the account... why it happens?
-
0
votes1
answer481
viewsSeparate words using split
I wanted to print out only words that have : in front Example: Coisa1:kit1:Coisa2:kit2;grupo;grupo2;grupo3 would appear only: Coisa1 kit1 Coisa2 kit2 public static void main(String[] args) { String…
-
0
votes0
answers79
viewsWanning :Cannot merge Cells
I’m having trouble in a form generation system, when it passes a certain appears Warning: Cannot merge Cells - top left and bottom right incorrectly specified Range r = s.mergeCells(1, 0, total, 0);…
-
0
votes0
answers848
viewsHow to get the http request body in the API
How do I access the body content of the request sent by the client? For example: @Override @GET @Path("/mypath") public Response myMethod() { System.out.println("Conteúdo da requisição: " +…
-
0
votes1
answer174
viewsSetting for date and time field
I’m setting 2 attributes, one will be date and the other time: @Getter @Setter private Date dataOcorrencia; @Getter @Setter private Calendar horaOcorrencia; I wonder if it’s the best definition for…
-
0
votes1
answer178
viewsload value in empty front form without starting with 0 [java] Thymeleaf + spring
my Entity is as integer and load n front with value 0, I think it is a simple thing but I do not understand much.…
-
0
votes1
answer110
viewslist to store objects
well, I’m creating a manufacturer’s list and I have a question regarding which collection to use. I want to add several manufacturers in my list, in case I use the LIST interface Arraylist? or some…
javaasked 7 years, 7 months ago user67378 -
0
votes1
answer948
viewsView PDF JSF primeFaces
Staff I am creating a pdf file up ai beauty. Now I would like to display this PDF in a formulário.Xhtml Below is the code I use to create the pdf in case someone can help me: Creapdfbean class…
-
0
votes1
answer124
viewsHow to download a PDF that is in C:
With the code below I can download a JPG, but with PDF does not work. I tried to change the last line for that, but it didn’t work either. file = new DefaultStreamedContent(stream,…