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
-
6
votes1
answer1385
viewsPrint text and image on Zebra printer
I used "Zebra Designer" to generate a "code" for the Zebra printer to interpret, but I don’t know how to add an image in the middle of that print dynamically, like... I have a tablet that the…
-
6
votes2
answers1457
viewsDoubt, java regular expression
I have the following regular expressions. The first one validates words and is right. The problem is the second one is to validate directory, for example…
-
6
votes3
answers3711
viewsHow to shuffle characters from a Java string randomly?
I’m developing a password generator program. In it the user can set the percentage of numbers, letters and special characters that he wants to have in his password, as well as the size of his…
-
6
votes2
answers740
viewsSwap whitespace for %20 in Java
I have the following URL: String Url = "www.minhaUrl/pagina/meus parametros tem espaços em branco"; I need to turn it into: String Url =…
javaasked 7 years, 8 months ago fernandoocf 1,095 -
6
votes2
answers525
viewsOpen java PDF on another machine
I did a function that I can open a PDF, but this function is only working on my local machine. When I run . jar generated on another machine, an error is issued that the Pdfnão file exists. The…
-
6
votes1
answer1243
viewsJava Thread Synchronization (synchronize collections)
I have defined a Thread in Java where I intend to simulate planes arriving and departing from the airport, the class Aviao contains only number and 10 passengers public class Aviao { //numero de…
-
6
votes2
answers7914
viewsWhat is the difference between Java Keywords extends and Java Implements?
I would like to know when they should be used and how we can distinguish them. I know that basically Implements, means that this class implements a class or an interface. E extends can access the…
-
6
votes1
answer290
viewsCalling up graphical interface in java
My doubt is simple, I believe. I need to call this interface CadastroGUI d = new CadastroGUI(); which I already have ready, but I want the fields already appear filled, after all, is a query command…
-
6
votes3
answers1311
viewsHow to place a upload image within a Javascript function?
I have this function below: function consultarOcorrencia(number, sequence){ form = document.forms[1]; form.number.value = number; form.sequencial.value = sequence; form.submit(); } After the submit,…
-
6
votes2
answers1184
viewsDifferences between System.out x System.err x System.in?
I didn’t find any debate on this question here in the community so I decided to create this topic. Follow a well-commented question among beginners in the Java language when it comes to data…
-
6
votes2
answers84
viewsDoubt interpretation function
I have a Hashmap users: private Map<String, ObjectOutputStream> utilizadores = new HashMap<String, ObjectOutputStream>(); Can anyone tell me what this function does exactly? Here under…
-
6
votes1
answer527
viewsThreads Server Client
In the following class SocketServidor send a single thread with the out and the in, but this class is supposed to be able to send two threads when running. You’re supposed to do this: The server…
-
6
votes2
answers98
viewsWhy println ran before printStackTace?
I was studying Exception Treatment in Java and I came to this question that I could not find on Google. Why in this example he printed the first line of the printStackTrace, and already gave the…
-
6
votes1
answer103
viewsHow to create an application from a Maven file?
I was working with EJB and dealing with four simple Maven projects, a web project ,a desktop project (JSE Swing), a project (JSE) that had only the interface and ultimately a web project (which I…
-
6
votes1
answer250
viewsHow to unify two Csss files
I’m doing a project Spring MVC 4.2. In this project I have more than one file CSS and more than one JS. What I want is to transform all the files Csss in a single ALL.css and that this file is…
-
6
votes1
answer712
viewsWhat is the concept of integers signed in a programming language?
I would like to clarify the meaning of the term "whole signed". I’m researching protocols, to build one in Java, and sometimes I find the term. I don’t know what it’s about. I’ve always heard of…
-
6
votes1
answer570
viewsWhat is the difference between revalidate() and repaint()?
When working with swing, we usually call one of these methods after some change in screen components. But after all, what’s the difference between using repaint() or revalidate()? In what situation…
-
6
votes3
answers497
viewsSeparation of string text into an array
I need a way to separate a string like the following: "0.1253729 09863637 02937382 029828020" I want to remove each of the information and store in one array. Obs: I’m reading from file .txt.…
-
6
votes3
answers246
viewsDeal with exception that guaranteed will not occur
Here is an example of a method to illustrate the context of my doubt: public void comprar(int numeroLoja, int numeracaoProduto, String nomeMarca) throws LojaNaoExisteException,…
-
6
votes3
answers1754
viewsWhat is called the replaceable method in the constructor?
In a class that extends JFrame, I have some calls on the builder, as can be seen below: public ListaDeOficiosUI() { try { this.oficioController = new OficioController(); this.initComponents(); //o…
-
6
votes1
answer304
viewsHow to simulate a logged-in user in an application with Demoiselle 2.4.2?
I have an app Demoiselle 2.4.2 already in operation that needs to use the SecurityContext to obtain the User currently logged in and make some decisions. The time now is to write the unit tests…
-
6
votes1
answer81
viewsJava type relationship or other language with processor architecture
Java has the primitive types: int and float, that store at most 32 bits of information, and we also have the types long and double that store 64 bits of information. Does this have or might have…
-
6
votes0
answers1020
viewsDigital Certificate Login ( E-CPF, E-CNPJ ) with Servlet / JSP
Hello. I’m looking to develop a login system similar to what government portals use ( E-CAC, NFE and the like ), where E-CNPJ is used to log in. I did the following: 1) I created and signed an RSA…
-
6
votes1
answer666
viewsPassing optional arguments in Java
I’m trying to learn how to run the class SwingWorker<T,V>, I’ve even done another question regarding one of its methods. Looking at the source code of this class, I found the method publish()…
-
6
votes1
answer2259
viewsUse of the Consumer interface
What is the advantage of using the interface Consummer java-like? Example: I have a class UsuarioConsummer implementing the interface Consummer and calls his way acept, follow suit: public class…
-
6
votes1
answer1727
viewsWhat is the difference between Type-safe and Null-safe?
I’m writing an article about Kotlin, and I came across these guys, if anyone can help me. What is the difference between Type-safe and Null-safe?
-
6
votes2
answers159
viewsBetter applicability to make an interface functional
Starting from java 8, for an interface to become functional, it needs to have only one right method ? However we have the @Functionface annotation, which explicitly defines that this interface is…
-
6
votes2
answers134
viewsProblem with return of a Java method
This method is giving problem in the return. An error message is appearing with the following statement Missing Return statement. Could someone tell me a solution? public String adicionar (String…
-
6
votes2
answers348
viewsRoot with Bigdecimal
I’m racking my brain to turn a root into a code. I know it works kind of like this: Math.pow(625, (1.0/4)) = raiz 4ª de 625 = 5 My headache is that my dice are BigDecimals Sting prazoIn =…
-
6
votes1
answer1128
viewsWhy put . jsp file in WEB-INF directory?
Taking Maven as an example, when starting a new web project, the structure is equal/similar to this: Meu Projeto |- src |- main |- java |- resources |- webapp |- WEB-INF Where, in the directory…
-
6
votes4
answers2533
viewsHow to split a string every 2 characters?
I’m trying to split a string every two characters, but I don’t have a delimiter and I need to use the whole string. Example: String exemplo= 99E65A78 String ex1= 99 String ex2= E6 String ex3= 5A…
-
6
votes1
answer2344
viewsMake a generic vector in Java
How to create a dynamic vector in Java with generic programming? This vector must have initial size 4 and be increased in size as new elements need to be inserted. The class must have: Constructor.…
-
6
votes3
answers390
viewsIs it possible to place objects in an Arraylist as soon as instantiated?
Doubt applies not only in one ArrayList, but in any kind of List. It is possible to add objects to ArrayList soon after we instantiate it, and without having to use the method add()? As can be done…
-
6
votes1
answer566
viewsExpression Calculator - Expression break problem
I’m going to college and I have to do an expression calculator on java, that is, basically if you write (5+5)/2 or something like that, it has to give you the right result. I had no problems with…
-
6
votes1
answer92
viewsWhat’s wrong with that code?
My college professor gave us this code and was asked what’s wrong: public class Teste { private static Teste INSTANCE = null; public static Teste getInstance() { if ( INSTANCE == null ) { INSTANCE =…
-
6
votes1
answer342
viewsDifference in thread execution in Java
See the execution of two similar programs in Java. One inherits from Thread and another implements the interface Runnable: Program1: public class PingPong extends Thread{ private String msg; private…
-
6
votes2
answers229
viewsArraylist statement with type or without
I’d like to know the difference in declaring a ArrayList in this way: List<BancoPerguntas> listaBancoPerguntas = new ArrayList<BancoPerguntas>(); List<BancoPerguntas>…
-
6
votes0
answers75
viewsThread in WAIT state
I am monitoring a system that was made in Java and at certain times during the day the vast majority of Threads, about 95%, enter the WAIT state and are waiting for about 50 seconds on average, and…
-
6
votes2
answers12870
viewsHow to consume an external API in Spring Boot
I have a springboot REST application that needs to extract information from another application. How I make this communication and can extract this data?
-
6
votes3
answers709
views -
6
votes2
answers2211
viewsHow to save images in the database using spring boot?
I’m having trouble saving images from a form in the database. Does anyone know how to save an image in the Mysql database using spring boot? I’m learning this technology now, so with this…
-
6
votes2
answers230
viewsInvalid Property 'category.subcategory' of bean class. Error saving user to database
I am developing a web application that has the following mapping: A user has a category; A category has several subcategories; a subcategory has several products. As shown below: What I am trying to…
-
6
votes2
answers4147
viewsWhat is the difference between Embeddedid and Idclass in Hibernate?
I have read in the Hibernate 5.0 documentation that you can implement composite primary keys using two ways. The first of these is using the annotation @IdClass and imitating the Idclass attributes…
-
6
votes1
answer166
viewsImplement Java Functional Programming Loop
private List<String> getPermissoes(TipoUsuario tipoUsuario) { List<String> permissoes = new ArrayList(); for (Permissao permissao : tipoUsuario.getPermissoes()) {…
-
6
votes2
answers614
viewsInterface and inheritance for the Java connection class
Considering the object orientation, would the use of inheritance and interface in this way be correct? But in this way, any request for connection to the database will need a new object. Would have…
-
6
votes3
answers5107
viewsWorking days and Java 8 API, how to check?
How do I verify that a day is useful using the Java 8 API? It is possible to check whether it is Saturday or Sunday, but how to check for example holiday like September 7 (Independence of Brazil) or…
-
6
votes3
answers720
viewsNullpointerexception Java JPA CDI Tomcat
Good afternoon guys. I am developing a Java test application with JPA, CDI and Tomcat. I created a basic test class and am getting the following error. Erro: Exception in thread "main"…
-
6
votes1
answer302
viewsDo you have anything like the C# namespaces in Java?
I noticed the size of the command to put a message on the screen in Java, wanted to know if it has how to decrease? As in C# that the programmer puts the word using "namespace"; and you can use the…
-
6
votes2
answers78
viewsIn Java would a variable receive a function like in Javascript?
Example: var x = function (a, b) { return a * b }; Could it be? Or is it a feature of Javascript?
-
6
votes2
answers562
viewsSwitch case Java ends without reason
I have an example of switch-case with 8 options. But from the case 7 he finishes the program. He was to return to the menu option after execution. The case has limit of options? Follows the code:…