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
-
3
votes2
answers223
viewsStatic constants
enum Animals { DOG("woof"), CAT("meow"), FISH("burble"); String sound; Animals(String s) { sound = s; } } class TestEnum { static Animals a; public static void main(String[] args) {…
-
3
votes1
answer261
viewsPrimefaces Mobile does not work p:Poll
I am implementing p:poll on a page that user can see their updated position in a queue. I tried to run on a page but it didn’t work, the updated queue position went blank in the field using…
-
3
votes4
answers3972
viewsjava.lang.Noclassdeffounderror: org/slf4j/Loggerfactory
good afternoon! I was trying to run a jar classes and came across the following mistake: Exception in thread "main" java.lang.Noclassdeffounderror: org/slf4j/Loggerfactory I searched and found this…
javaasked 8 years, 11 months ago Andreia Oliveira 69 -
3
votes1
answer226
viewsHow to implement Service Layer with Spring?
Does anyone know any tutorial, examples... any source to learn how to implement service layer?
-
3
votes1
answer45
viewsIs there an Aot compiler for Java?
I’ve seen the Excelsior Jet but it is private and paid. If there is any free, how do I use it in windows? (I say this because there is so much for linux)…
-
3
votes1
answer1209
viewsIs there any object recognition framework for Android?
I wonder if you have knowledge and if there is a framework for recognizing objects, people, anyway, things, ready to be used on Android. It’s similar to the idea of the app Google Goggles and the…
-
3
votes2
answers74
viewsI wonder if every time I create an object in java it initializes a Thread
I have a class that extends the Thread class, wanted to know if every time I create an object it initializes a Thread. class Objeto{ String nomeObjeto; public Objeto(String nomeObjeto){…
-
3
votes1
answer97
viewsIs the Mediaplayer.create() method called in the background?
I was reading the documentation of Android Media Playback and a doubt occurred to me. In the documentation it said that it is not advisable to call the method mediaPlayer.prepare() in thread…
-
3
votes2
answers314
viewsError related to binary tree removal and child relocation (java.lang.Nullpointerexception)
Hello, everyone. I started studying the Java language recently and decided to try to create a binary tree with three features: 1 - Add element to tree 2 - Search and print tree widget 3 - Remove…
-
3
votes1
answer404
viewsError in monetary mask, saved with the right digits but at display time 2 digits are missing
Colleagues! When I save the product gets the correct digits as on the screen above. However, when I enter the list of products and click on the product Scissors it opens on the registration screen…
-
3
votes1
answer33
viewsHow to rescue Edittext values created via script?
I have the following code that creates 4 Edittext in Layout: LinearLayout myLayout = (LinearLayout) findViewById(R.id.formulario); ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(…
-
3
votes1
answer132
viewsCopy, Paste, and Crop an Array of Java Integers using Clipboard?
Personal greetings, I was trying to perform the processes of Copy, Paste and Cut using an Array of integers in Java, but I found a lot of difficulty and little material (mainly in Portuguese).…
-
3
votes1
answer695
viewsCannot get a text value from a Numeric Cell "Poi"
I am trying to consume data from a spreadsheet in excel, but always gives this error, already tried to format the spreadsheet for text and for number and even then the error persists. How do you fix…
-
3
votes4
answers498
viewsFull byte type cast
I have the following code: public class Principal { public static void main(String[] args){ int i = 10; byte b = 5; b = (byte)i; b += i; i = b; System.out.println( i ); } } I know the value returned…
-
3
votes3
answers7481
viewsCompare Two dates and time
Good morning guys, I’m trying to compare two dates but I’m not succeeding. I have 2 dates: dataAtual and dataPedido. What I want to do is that if the dateAtual is equal to datePedido and if the…
-
3
votes1
answer108
viewsSelect Hibernate + ifrebird
Guys I’m having a mistake in making the select !!! follows the class and error Advertência: #{mbeanUsuario.Vusuario}: javax.persistence.PersistenceException:…
-
3
votes0
answers610
viewsFirebird 3.0 connection problem with Java 1.8
I am having problems trying to connect to Firebird 3.0 using Jaybird 2.2.7, when performing the test with Firebird 2.5 I can make the connection to the database, but when trying to do it with…
-
3
votes2
answers212
viewsProblems to delete repeated numbers in an Arraylist<String>
I’m having trouble getting repeated numbers out of a ArrayList, here is the code snippet: for( int i = 0 ; i < houses.size(); i++ ) { for( int j = 1; j < houses.size(); j++ ) {…
-
3
votes1
answer1282
viewsHow to call builders with arguments?
How to define constructor values in the main class by Scanner in such a builder?. public Aluno(String nome,int idade) { this.nome = nome; this.idade = idade; } and in the main class call: Aluno…
-
3
votes1
answer273
viewsCustom Session generated by spring
I have the following scenario: an application nodejs that saves the session in redis. another spring q application also saves the session in redis. I would like to share this same session between…
-
3
votes2
answers728
viewsError in converting JSF
Error or Bug? Well I have an error appearing in the eclipse console, on the registration screen the form records perfectly, everything ok, but the console points: java.lang.NumberFormatException:…
-
3
votes1
answer184
viewsPrint more than 1 java value
I’m studying matrices. The matrix is in characters information of the game of Thrones. My matrix: public static String [][] matrizPrincipal() { String [] [] matriz = new String [6] [114];…
-
3
votes2
answers3168
viewsCount duplicate values in list
I have a ArrayList with multiple numbers inside it. I need to identify how many times each number appears and then eliminate redundancies. I was able to eliminate redundancies, but I’m having big…
-
3
votes1
answer6183
viewsHow to transform JSON into object array of a specific class, where this class has composite attributes?
I found the following problem when trying to transform a String JSON in object list. I have the following situation: I have a class Response which has some attributes, among them a list of "Post",…
-
3
votes1
answer57
viewsFakehttpserver breaks when upgrading to Jetty 9
I’m migrating an application that used the Jetty 7.4.5.v20110725 to the Jetty 9.3.0.M2, using the Maven. I’ve already updated the javax.servlet-api to the versão 3.1.0. But, I’m using the…
-
3
votes1
answer775
viewsWhy can’t I see Javac?
Colleagues. I downloaded sdk jre1.8.0_73, but I can’t see javac inside the bin folder. I already created the environment variable and still nothing. This version no longer exists javac?…
javaasked 8 years, 9 months ago user24136 -
3
votes1
answer205
viewsHow do I know if there was a glitch in texting?
I have this method of sending SMS via app: public boolean enviaSMS(String fone, String mensagem) throws Exception { try { smsManager.sendMultipartTextMessage(fone, null,…
-
3
votes1
answer1677
viewserror: cannot find Symbol - Maven install with class Folder
I have a Maven eclipse project that uses a Folder class. That folder has the . java and .class. The classes I use in the project are in build path as class Folder, when I do Maven install it gives…
-
3
votes2
answers264
viewsServer Side Only Rest Api
Hello, I have a restful Java api using Jax RS that will be consumed by another application that will be online. I would like to prevent people directly accessing the api, and yes, only by the web…
javaasked 8 years, 9 months ago Ricardo Farias 439 -
3
votes1
answer477
viewsIF condition is true but does not execute related code
I have my program that displays a message and in that same message the user must enter a code. I’m trying to validate whether he typed something or not, so I use the code: AlertDialog.Builder alert…
-
3
votes2
answers510
viewsWhy does the main method receive parameters?
public static void main(String[] args) What does this String array that is passed as a parameter mean? How these parameters can be useful to the developer?
javaasked 8 years, 9 months ago Bruno Brito 2,850 -
3
votes0
answers169
viewsPrinting houses in Bematech
I Googled but I couldn’t find any material that would help. How can I send a print from an Android app to a non-fiscal Bematech printer that is connected to a computer on the same network as Mobile?…
-
3
votes1
answer1452
viewsRemove Printer Dialog - Printjob Java
In a Java application I do the printing through Printjob, but in the way I do the printing by calling the Print method it opens a printer dialog box so I choose which one to print, I tried and I…
-
3
votes2
answers1199
viewsWhere to close Entitymanager
I am developing a Java application, and I am doubtful where to close the Entity Manager. I have an abstract class AbstractService<T> which is extended by all entities of the system, and this…
-
3
votes1
answer120
viewsAre methods and builders the same?
Some sources say that constructor is a special type of method, while others say constructors are not methods. Some say, too, that although they are different the JVM treats them the same way. After…
-
3
votes1
answer367
viewsWhat does equals(Object o) mean in this method?
In that code: public boolean equals(Object o) { Aluno outro = (Aluno)o; return this.nome.equals(outro); } What’s he good for?
-
3
votes3
answers917
viewsFormatting String with Dateformat using a Timezone is not working
In my web service, there is an endpoint that returns a timestamp to me UTC and I have a method that generates a date formatted from this timestamp: formatDate(1432313391, "UTC"); public String…
-
3
votes2
answers238
viewsGeneralization of parameters in Java
I am implementing a B tree for a database job in Java, so that it stores any kind of objects, be generic, so I am treating as if it were Object, but in some parts of precise code methods such as…
-
3
votes2
answers140
viewsProblem inserting data into a vector
I have the Door, Building and Main classes: public class Porta { boolean aberta; String cor; double dimensaoX, dimensaoY, dimensaoZ; void abre() { this.aberta = true; } void fecha() { this.aberta =…
-
3
votes2
answers3170
viewsIs it possible to store an Arraylist in a Java database?
In the case of Banco de Dados using Java, it is possible to store an object ArrayList in a Banco de Dados MySql? If yes, how can I store this type of data? And how can I recover it from the Data…
-
3
votes1
answer616
viewsHow to get the name of the remote user connected to the java server?
I have a problem that I do not know if it is possible to solve, I am in the development of an intranet system and I need to get the name of the local user(ie in pc client). tried to use…
-
3
votes2
answers496
viewsProblem with Fileupload
I had the opportunity to find an application ready on the internet as shown below:…
-
3
votes1
answer5140
viewsConvert string to Calendar
Well I need to do a String to Calendar conversion and I have to set the value in a variable (that is in type Calendar) in a class and then insert the data in a database! System.out.println("Digite a…
-
3
votes2
answers872
viewsHow to leave a Alertdialog with rounded edges?
When I want to make a Dialog customized I just put one layout inside it. But around it Dialog is square, someone knows how to round?
-
3
votes1
answer48
viewsProfile network java (jdbc)
What tool can I use to evaluate the response time of a request (jdbc) Ex: query = "SELECT * FROM v$version WHERE banner LIKE '%Oracle%'"; ResultSet rs = stmt.executeQuery(query); // linha de cima ⋀…
-
3
votes2
answers2051
viewsDevelop integration tests correctly
We are writing several tests for the application, there are testes unitários and we started testes de integração. All communication with DAO is mocked, but when I test the API I should re-test the…
-
3
votes2
answers3331
viewsCheck whether the attributes of an object are null in a less manual way
How to solve this: Objeto obj = new Objeto(); if(obj != null){ //executa o codigo } The question is: have I instated the object, beauty? Only I have not set any value for it so all its attributes…
-
3
votes0
answers399
viewsEmpty bean with Primefaces
I created a page with a datatable and to register something I display the form on a p:dialog of Primefaces works perfectly, but when I create the layout of Primefaces to put my page inside the…
-
3
votes2
answers247
viewsDoubts regarding the use of the Java 8 stream
I’m practicing some new things that came with Java 8 and between those the use of Stream. I have heard that when we do some action in a list using the stream, it does not change the value of the…
-
3
votes2
answers2111
viewsHow do I connect a database to a JAVA application
I have an app Java and a database MySQL connected in this application on my machine. The application will be distributed to other machines on the same network, but I can’t connect the banco de dados…