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
-
8
votes1
answer428
viewsWhat are the differences between the methods "equals()", "compareTo()", and even "=="?
I am aware that there are differences between comparing objects using equals(), compareTo() and even the operator ==, but in detail what are the differences between them and the care we should take…
-
8
votes6
answers422
viewsHow to "call" this correctly?
When the Elements are inside the onCreate, use the (this) it’s very easy... Example 1 : that works from within onCreate itself protected void onCreate(Bundle savedInstanceState) { Spinner spinner =…
-
8
votes2
answers941
viewsImport multiple classes from the same package
I wonder if there’s any significant difference in making import java.util.* instead of import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.List; import…
-
8
votes2
answers701
viewsjava email sending does not show error when unable to send the same
I created a system where the user registers and the password is sent by email. If you cannot send the email, it generates an error and does not create the user, notifying the same. It was working…
-
8
votes3
answers8606
viewsSwitch case Kotlin
In Java I use the switch in various situations, as in the example below: public class SwitchDemo { public static void main(String[] args) { int month = 8; String monthString; switch (month) { case…
-
8
votes1
answer214
viewsHow to compile a Java 9 project with Lombok in Gradle?
TL;DR How to pass multiple parameters -J--add-opens=<pacote>=ALL-UNNAMED so that Gradle uses them when calling javac? Details I have a code Helloworld.java using the Lombok in Java 9: import…
-
8
votes2
answers749
viewsHow to put icon on Joptionpane buttons?
How do I place an icon in the "Continue" and "Cancel" buttons that appear in the JOptionPane? The case is represented below: public void metodo(){ JPanel panel = new JPanel(); JLabel label = new…
-
8
votes3
answers337
viewsHow to find the occurrence of equal integer values in a vector?
I need to find frequency of ages in a vector. I know how to do this when the vector is small, but not when it is large. Consider the vector below: int[] idade =…
javaasked 6 years, 2 months ago Van Ribeiro 1,482 -
8
votes1
answer329
viewsImporting the java.lang. package*
Adding the studies in Java I came across a package so much that special, the java.lang, where the author of the book mentions that we do not need to perform the import of that package. There’s a…
-
8
votes2
answers828
viewsParametric polymorphism and overload in Java and C++
The following question fell in IFSP’s tender procedure: In Java and C++ programming languages, parametric polymorphism is materialized, respectively, by the functionalities and/or characteristics:…
-
8
votes3
answers644
viewsHow to create a "Main" in an application that consumes a REST service that has all the entities in the system?
I am with the following web application created initially for and web using Spring Boot, Spring Security and Thymeleaf (authentication and authorization). I did a REST job and separated the…
-
8
votes2
answers145
viewsHow to get all interfaces of an object?
I need to list all interfaces that an object implements. From what I understand, I could do the following: Object misterioso; .... misterioso.getClass().getInterfaces(); but this would only take the…
-
8
votes1
answer380
viewsHow to remove the background of an image using Watershed on android?
I’m developing an app that classifies images of wounds. For this, I need to highlight the region of interest of the background to facilitate the work of the classification algorithm. The user uses…
-
8
votes0
answers77
viewsWhat is a Memory Model?
Reading the Wikipedia article in English discovered that Java was the first popular language to have a memory model in the presence of well-defined threads, followed by C++11. Reading the article in…
-
7
votes1
answer971
viewsController and service annotations
In Spring 3 there are class annotations @Component, @Service, @Controller and @Repository. I know that the @Component is the only one that can be used in all cases (Controller, Service and…
-
7
votes2
answers321
viewsWhich tool to use to generate releases in Java?
I am developing my first project in Java, the application is an API using several libraries, among them: Jetty, Hibernate, Httpclient, Jasperreport... In this project I use the Maven framework, I…
-
7
votes1
answer1242
viewsControl module version with Maven
I have a multi-module Java project with Maven. Currently, I control the version of each module manually, editing the element <version> pom.xml for each module that undergoes updates. I believe…
-
7
votes1
answer658
viewsHow to generate Jlabel or Jtextfield at mouse click?
I wonder if there is a way to generate a JLabel or JTextField at the position where you click, on a JPanel or a JFrame. It is possible?…
-
7
votes3
answers1689
viewsHow to read file passing part of the name in Java
Example.: The name of my file would be 001nome.txt, this file will have a varying action on the name depending on the entity, ie one time it may be 001nome.txt another time it may be 999nome.txt.…
-
7
votes3
answers232
viewsChange CRT file to byte
I need to convert a file .crt byte to be able to send by socket. This code works in Java, but how would I write it on Android? Path path = Paths.get("sdcard/certificado.crt"); byte[] certificado =…
-
7
votes2
answers338
viewsHandle price in stock control
I’m making a stock control system in Java and came across a question about how to store prices. I’ve been reading that double and float are not good to store this kind of data and about a data loss…
-
7
votes2
answers355
viewsMaximize Solution: Sublist Construction Meeting Limit
Having a set of n-values, I need to divide these items into subsets that do not exceed the value (sum of all items) stipulated and assure me that the formation of the set is as close as possible to…
-
7
votes1
answer915
viewsValidation of business object avoiding/reducing use of if’s and Else’s
I have a problem where I have three types of employee (Funcioa, Funcionariob, Funcionarioc), all will be recorded in a table called Funcio and their respective relationships, however, these types…
-
7
votes1
answer523
viewsWhy is it risky to run Java applets in browsers?
In my company, we have two websites that need a Java applet (to authenticate using digital certificates). And these two sites give a lot of headache, mainly, whenever Oracle releases an update from…
-
7
votes3
answers7833
viewsCount elements in a Java Arraylist
I have a Arraylist calling for tracklist within the class Album, that contains a number of songs. I need to go through and return how many songs are within the album through a class I named…
javaasked 10 years, 7 months ago user3000135 127 -
7
votes1
answer2472
viewsProblem in converting number (Numberformat)
I’m having the following difficulty, picking up a value through my form: Double salario = Double.parseDouble(request.getParameter("salario")); Since the value typed by the user will be something…
javaasked 10 years, 7 months ago Lucas Olivier 73 -
7
votes2
answers36959
viewsHow to generate an executable program . jar in Netbeans?
I made an application in Java and liked, now I need to get executable to show my colleagues. How do I get the executable?
-
7
votes1
answer1317
viewsJava encryption with AES, how does it work?
I have found several examples by Google, but none that explains how a java encryption works with AES... How it works? In an example of the net, the guy quotes that he has to use a key, but it…
-
7
votes2
answers822
viewsWeb application running in background
I am working on a Java web application, and I am creating and planning some specifications. In some specific modules I need some runs running in the background on the server. For example, the user…
javaasked 10 years, 3 months ago Erico Souza 2,188 -
7
votes2
answers57495
viewsFormatting a double in java
I would like to know how to keep the variable double with 2 houses after the comma. Below I have an example, when transforming a String in double if it has values after the point is kept the 2…
-
7
votes2
answers1336
viewsJavafx application does not run on some computers after exported to jar
I developed a Javafx application, created an Ant script through build.fxbuild and ran a jar. The generated jar runs Ok on the computer on my service and on another developer’s computer, however it…
-
7
votes1
answer402
viewsPercentage of Equality of Texts?
Is there any method to know the percentage of equality of two texts (Strings) in Java? An abstract algorithm would also serve.
-
7
votes3
answers3288
viewsWorking with delay’s on Android. Best approach?
Doubt I recently needed the use of a delay in my application to run certain code, after some time. Searching "over the internet", I found some "Gambi’s", and I found a somewhat new approach for me,…
-
7
votes4
answers4670
viewsSelect string at random
I need a way to randomly create a string between some options. Let’s say I have the strings "A" "B" and "C", it would be possible for Java to choose randomly?
-
7
votes2
answers963
viewsHow to get the public IP of a connected user via socket?
I need to get the IP address of a user who will remotely connect to my program, and list it, the program itself is a chat where only the server will store the IP address of the users. Client…
-
7
votes2
answers2322
viewsHow to save/recover image in memory on android?
Hi, I have a Array of Bytes which is a image, from it, how can I save in the external memory and if there is no save in the internal memory android? and then how can I be recovering this image? I…
-
7
votes1
answer525
viewsHow to determine if a point of a swing component is visible on the screen?
How do I determine if a certain point X within a swing component is visible on the user screen? For example, let’s assume that the JComponent To was added to a window B (normally, but not…
-
7
votes1
answer329
viewsPolymorphism in Java
Example: // Super classe: Carro abstract public class Carro { String nome; public void andar(){ // anda } } // Sub classe: Fusca public class Fusca extends Carro { public void andar(){…
-
7
votes2
answers1104
viewsDoubt how to configure Spring Data with Hibernate
How to set up Spring Data + Hibernate Hello everyone, I’m new here in stackoverflow and also in java web development. I am etudando some things of Spring Frameork and I am with a doubt of how I can…
-
7
votes4
answers10421
viewsHow can I get a date (day, month, year, time, minute, and second) converted into milliseconds in Java?
How can I get a date in milliseconds? Example: 24, Sat, Jan, 17:39:50 2015
-
7
votes3
answers2508
viewsHow to work with OCR to recognize photographs
I am currently working on my Course Completion Work and the theme involves OCR. I did some research and found the Tesseract, I also found libraries in Nuget for him (I’m using C#). The problem is…
-
7
votes1
answer9427
viewsI can’t update my app on google play?
I know it is necessary to change the version number, but when I make the change and try to generate an apk gives error and shows me a message... Error:XML version "2.0" not supported; only XML 1.0…
-
7
votes2
answers455
viewsJAX-RS Resource as Session Bean or CDI Managed Bean?
Today I ran into an interesting problem trying to inject an EJB into a JAX-RS feature (in Glassfish 4.1, running the pre-installed version of Jersey). @Stateless public class MeuEJB implements…
-
7
votes2
answers1998
viewsHow to close a Jframe using keyboard events?
I have a Jframe that I want to close when I press the Esc key... Well, I did that: public Cadastro() { addKeyListener(this); And then that: public void keyTyped(KeyEvent evt) { if(evt.getKeyCode()…
-
7
votes2
answers8611
viewsHow to justify the text in a Textview?
It is possible to justify (align) the text of a TextView? Besides justifying, I want to apply other types of formatting.
-
7
votes1
answer2924
views -
7
votes4
answers342
viewsWhat is the function of the " | " operator within the catch?
I read that || (OR) is for boolean operations and | (Bitwise Operation) for bit operations. What is your function within a catch with multiple exceptions, then? I mean, I know it eliminates…
-
7
votes2
answers4016
viewsPays to migrate from Swing to Javafx?
Currently most of my applications are made with Swing. I’ve done 2 small projects web with JSF+Primefaces+Hibernate. My question is this:: It pays to quit Swing and study Javafx, or it’s better to…
-
7
votes3
answers3334
viewsClose Windows popup in Java (Selenium Webdriver)
I am testing a site in java and need to close a Window pop-up, the problem is that I tried to use Selenium to close it and I could not. Is there any simple way to close it using JAVA? You don’t need…
-
7
votes1
answer1357
viewsProblem placing multiple data from a list in a report
Good morning guys, this is a somewhat complicated question to explain, so I will do my best to make the question clear. I have a list <UnimedLote>. In this list I have several data, among…