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
votes2
answers300
viewsHow to create an array through another?
I have a problem that deals with providing an array to the program and this should return only the odd numbers of this array, and for this I create a new array that receives the values: public void…
-
2
votes2
answers1284
viewsForeach with lambda which returns the sum of iterated items
I’m trying to iterate on a List calling for produtos of objects called Produto, using the forEach, to obtain the sum of the values of these products using the lambda function of the forEach. But I…
-
2
votes1
answer58
viewsNullpointerexception when trying to use interface to pick up data from one Ragment to another
I’m doing a program that creates graphs, that contains a page with two tab Fragments one for the graph and another for the algorithms I’m trying to make when a button is clicked on the algorithms…
java android android-fragment nullpointerexception interfaceasked 5 years, 7 months ago Gabriel Ricardo 31 -
2
votes0
answers94
viewsgenerate PDF with Jlabel BLOB image that comes from mysql database in itext
Good morning, I am with a java desktop program and my problem is in generating PDF with itext, with the BLOB image coming from mysql database, the same is being shown in Jlabel inside a Jpanel with…
-
2
votes2
answers894
viewsHow to return a "not found" feature in Spring?
I’m running some tests on Spring to return error 404 in case he doesn’t find one id when searching in Repository, but is giving 200 OK. @RequestMapping(value = "/{id}", method = RequestMethod.GET)…
-
2
votes0
answers168
views -
2
votes1
answer581
viewsHow to use HTML files from the Assets folder in a Webview
I know there are several similar questions, but in all of them I have found no method to help me. As it is in Activity: package com.example.guilherme.webviewteste; import…
-
2
votes2
answers707
viewsWhy use Legacy Interface instead?
I would like to know why in java one should usually prioritize the use of interfaces, rather than inheritance with classes.
-
2
votes1
answer509
viewsHow does the Composite design pattern work in theory?
How does this pattern work in theory? What kind of problem does it solve and what utilities does it bring or something?
-
2
votes1
answer241
viewsHow to generate JAR and POM project by following the Maven repository layout?
I have a project where I need to generate the jar and pom following the same method as the plugin Maven-install-plugin generates within the local repository, as in the return that is given when…
-
2
votes0
answers69
viewsWhy doesn’t my Managedbean receive the amount passed on the xhtml page?
I am in error of those who can no longer visualize the problem and maybe, you "looking from outside" can help me. The question is simple, I’m not getting the value of an input from my view in…
-
2
votes2
answers412
viewsReuse code on multi-button onClick
I’m developing an app where it will contain several buttons. I need your help to see if I can improve the code. Actions do the same thing just change the background color and pass me the button…
-
2
votes1
answer1911
viewsHow to switch between Java 8 and 11 on Ubuntu?
I made a few days ago the transition from Windows 7 to Ubuntu 18.04 LTS, and had some difficulties in the process. Well, let’s get to the details. I installed JDK 11 through the following command:…
-
2
votes1
answer36
viewsWhy is it possible to delete an exception "release" statement from the signature of an inherited method?
I would like to know because I did not understand this part, it is because it is a statement that it can "launch" an exception? //EXEMPLO public abstract class Personagem{ public abstract void…
-
2
votes1
answer693
viewsHow to read a JSON from a second link of an API?
Speak guys, trying to get JSON, a second link that is provided by the API. But it gives error. Follows the code: private static String URL =…
-
2
votes1
answer203
viewsIs it possible to use variables to set the size of a View?
I am beginner in the development and applications and the application I am working in need that the user give me a value (distance in meters) and from this value I will adjust the size of the image…
-
2
votes1
answer161
viewsConfiguring port in Tomcat
I am developing various services and these are run at port 8080 by Tomcat. Since the next services to be generated are unrelated to the services that have already been generated, it was requested…
-
2
votes2
answers100
viewsRead Jlist files and display content in a Jtextarea
JTextArea caixaTexto = new JTextArea(); try { String[] arrayLinhas = null; int i = 0; BufferedReader br = new BufferedReader(new FileReader(diretoriaExecucao + "/" + valorSelecionado));…
-
2
votes0
answers533
viewsTabview in Primefaces with Ajax
Next, I have a small problem, but I am following the same steps of the showcase of the first faces, but without success. I want you to fire an ajax every time a tab is selected, clicked. That way…
-
2
votes1
answer195
viewsStart a thread again
I have an event on the start button, every time I press 3 threads are generated that start the count from 30 to 0, to which reach 1º to 0 wins. But however I press the start button a few times and…
-
2
votes2
answers123
viewsI have a logic problem to filter the registration and editing of my consultation schedule
I am Using the Schedule component of Primefaces(6.2) My project uses: Postgres, Hibernate, JSF. With the code this way I can register a new schedule and I can’t add a new schedule for the same…
-
2
votes0
answers56
viewsError installing Java on virtual machine
I’m trying to run a playbook (Ansible-playbook -i hosts.ini.yml file) that installs the java on my virtual machine, but it accuses error in the installation task: FAILED! = > {"changed": false,…
-
2
votes0
answers57
viewsHow to select options in java console application?
There is the possibility for the user to select menu options by navigating with the arrow keys up and down, then pressing enter? public static void menu() { print("=====MENU====="); print("|Novo…
-
2
votes1
answer35
viewsComplex type Android ksop2
I’ve been working for days developing an application that consumes a Soap web service. Sending a complex type I’m getting, as I should do to send more of a complex type? The integration key I can…
-
2
votes2
answers188
viewsIs it possible to return a variable from an object-oriented class without using a function?
I do not know if there is this possibility. Follow a code to assist in the question: public class Square { int side; public Square(int side) { this.side = side; } int getArea() { return side * side;…
javaasked 8 years, 1 month ago Iago Coutinho Campos 490 -
2
votes3
answers231
viewsHow to crop a String and convert to int in Java?
How can I cut out the String monthAndYear, convert and assign variables respective? At the time of conversion shows an error. System.out.print("Enter month and year to calculate income (MM/YYYY):…
-
2
votes1
answer288
viewsNo Mapping found for HTTP request with URI [/Milicia] in Dispatcherservlet with name 'Dispatcher'
Does not find the uris that I type, always gives the same error, I have remade and still the error persists. Follows the relevant classes and files. relevant part of pom.xml <build>…
-
2
votes1
answer263
viewsResize TAB spacing in Jtextpane
I want to change the tab key of jTextPane because it has many spaces, for example: It is currently found like this: Uma casa azul // após TAB Uma casa azul And what I want would be like this : Uma…
-
2
votes2
answers1661
viewsHow to sort a Map by key in Java
I’m trying to use a loop to show the grouped information of a Map. for(Map.Entry<Date, List<Exam>> entry : groupedList.entrySet()) { setNewList(entry.getKey(), entry.getValue()); } But…
-
2
votes1
answer430
viewsUnit tests on a CSV file upload
Before explaining my problem I will show my CSV file upload code. public String uploadArquivo() { try { removeInSession(LISTA_TIPO_INDICIOS); removeInSession(LISTA_INDICIOS);…
-
2
votes0
answers39
viewsTable not found HIBERNATE
I was doing some tests with Hibernate using abstract classes to create a kind of inheritance and generate my DB from the classes, but I got a problem trying to persist. The case is, I have an…
-
2
votes1
answer159
viewsOpen Form Popup on the same page
I need that on the home page in the "EHS" Menu, when clicking on the "SMAT" submenu open the form "https://collab.intra.fcagroup.com/sites/cma/EHS/Lists/InserirSmat/Item/newifs.aspx" in a popup on…
-
2
votes1
answer77
viewsSet Variables by Java Constructor
It is certain to "set" the variables passing by parameter directly in the constructor, equal to this code? public class Retangulo extends FiguraGeometrica{ private double largura; private double…
-
2
votes2
answers697
viewsClasscastexception error when trying to cast between classes
I have the problem to perform a "Cast" in a class, when using the inherited class method of the following error: "entity. Aula cannot be cast to tableview.Aulatv" Here gives the exception described…
-
2
votes1
answer171
viewsRegex for split comparison operators
I’m having trouble putting together a regular expression that meets the following condition: String formula = " 100 != (50 + 20 + 30) "; String arr = formula.split(" somente os caracteres: '=',…
-
2
votes1
answer134
viewsProblems with LAZY - could not initialize proxy - in Session
I have a problem trying to load an object that is mapped as LAZY. I mapped my attribute this way: @OneToOne(fetch = FetchType.LAZY) private Obra obra; And I load the data at the time of opening the…
-
2
votes0
answers197
viewsHibernate JPA locks
When you run persistence to create tables in the database netbeans hangs the exits on this item Oct 26, 2016 3:11:05 pm org.hibernate.dialect.Dialect INFO: HHH000400: Using dialect:…
-
2
votes1
answer56
viewsHow to take only one value of a Random variable and turn it into a constant?
How do I get only one value from a variable you use Random and store in another variable? It is possible? Wanted to store what will appear to the user int cartaUnoPersonagem = new…
-
2
votes2
answers1383
viewsPrint current month and the next two months
I’m taking the current month in number and need to increment it two more months ahead, besides using the current month and saving in a string array. I’m taking the whole and retrieving the name of…
-
2
votes1
answer114
views -
2
votes1
answer156
viewsBean dependency injection on Tomcat
I was trying to get an emergency injection, but I’m not following. I’m studying for the Web Components test, so I was practicing some code. I’m following an example given by the Tomcat 7…
-
2
votes2
answers2249
viewsHow to release CORS to a particular address?
I’m not getting the release CORS for http://localhost:8080, am using Spring Security. I find the following error: Xmlhttprequest cannot load http://localhost:9991/login. Response to preflight…
-
2
votes1
answer77
viewsWere the Wrapper classes depreciated in Java?
I’m following a sequence of old video lessons, in the video, Java 7 is used and the following code compiles: Long var3 = new Long("100"); I tried to compile and received the following message: Note:…
-
2
votes2
answers131
viewsScanner - Split regardless of the number of columns
public void lerFicheiro(){ try { Scanner scanner = new Scanner(ficheiro); while(scanner.hasNextLine()){ //quando numero de campos for igual a 4 String designacaoAeronave = scanner.next(); String…
-
2
votes1
answer286
viewsHow to update a form with ui:repeat without duplicating oc fields in jsf?
I’m having a problem with my ui:repeat components, I want to update and not repeat the components, have as? my form: <h:body> <h:form > <h:outputLabel class="col-sm-2 col-sm-2…
-
2
votes1
answer229
viewsHow to add a Library in the main module [ module-info.java ]?
I use the jssc package to access serial port. I added it to the main module module DeskCheck { requires java.desktop; requires java.logging; requires jssc; } But I believe I’m doing it wrong,…
-
2
votes1
answer374
viewsHow to test java exceptions using spring and Junit 5 lib?
I’m in doubt about how to test my java exceptions using the Spring Framework’s own resources. I’m testing a class called UsuarioValidator.java and in it I have a method called…
-
2
votes1
answer150
viewsHow to create Tablecellrenderer for strings?
I wanted to know how to make a Tablecellrenderer for strings. on this topic here: How to use a selection setBackground in custom Renderer? I saw that the guy had to "values". I wanted to know if to…
-
2
votes3
answers110
viewsJSF panelGrid does not work
The code below should show a simple screen divided between the names and input areas, but the panelGrid is not working, what’s wrong? When executing nothing appears. <!DOCTYPE html> <html…
-
2
votes1
answer889
viewsconvert whole to java string
How do I convert the Integer to String type in Java? The variable matricula is declared as whole, but to show it on the screen it asks to convert it to String.…