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
-
1
votes1
answer2019
viewsHow do I get the size of a Java String?
I’m creating a fake bank in java but I don’t know how to check if the password has 8 characters. public void criarSenha(){ String senhacriada = (JOptionPane.showInputDialog("Qual a senha ?"));…
-
1
votes1
answer343
viewsCollecting links in a text file
I have a problem in my program where I have to get links in the entire text file. I used regex to collect the links, however, only a few lines are captured (the file has approximately 3500 lines)…
-
1
votes1
answer31
viewsDifference between Activitycontext and Applicationcontext
What’s the difference between ActivityContext and ApplicationContext? The following code, executed from a Fragment, log the message "are different": if…
-
1
votes1
answer79
viewsJSP Project with Database
I am working on a JSP project with database my driver is not being recognized. I am using the following method to connect to the bank. public ConnectionDB(){ try {…
-
1
votes1
answer48
viewsApplication problem read xlsx file in centos error: libgcc_s.so. 1: Wrong ELF class: ELFCLASS64
I have a big problem and I can not solve tried to look for some tips on the internet but it did not work. That’s why I’m here and I was wondering if any of you could help me. I have a web…
-
1
votes1
answer22
viewsFind out the number of _search requests made to an Elasticsearch index
I am working with Elasticsearch and would like to find out a precise way to know how many requests have been made to an index of my Elasticsearch. using the GET - /"seuindex"/_Stats command, I have…
-
1
votes1
answer77
viewsProcessing 3.2.1, Game Control Plus library, java Exception
Good! I am studying Games & Apps Development and in our first semester we are doing a game in Processing. In my game I’m using a PS4 controller with the help of the library Game Control Plus. If…
-
1
votes1
answer65
viewspdf export of a web application, error: org/apache/poi/ss/usermodel/Workbook
Good evening. I am wanting to export to PDF of a web application with JSF and am having the following error: Stack Trace: java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Workbook at…
-
1
votes1
answer53
viewsInclusion of`final` by Eclipse after saving file
When I am working in some class and save the changed file, for some reason Eclipse adds final in random vegetarians, I don’t know the criteria that Eclipse makes this change, but it bothers too…
-
1
votes1
answer452
viewsSolve mathematical expressions in java using string
I cannot make this code solve the expressions contained in the database. In the database, the expressions are like this: All expressions registered in the database follow the pattern described…
-
1
votes1
answer309
viewsConnect to oracle 11 c
I am trying to connect on oracle 11 c and the connection is not performed. Gives error: ES Error: Got Minus one from a read call > I’m testing the query in a Servlet, I’m not searching for the…
-
1
votes1
answer33
viewsJAVA functionality compared to Delphi to find a value in a specific list
Hello, would someone like to tell me if there is a feature in JAVA similar to Delphi Locate? If Lista.Locate('REGIAO;PRODUTO', VarArrayOf([REGIAO.AsString, PRODUTO.AsString]),[]) Then[...]…
-
1
votes1
answer83
viewsTwo Intents starting the same Activity
I have a button to include a Hint and I have another button to edit the Hint already created. I would like to use the same creation activity, when it is for editing would pull the data already…
-
1
votes1
answer102
viewsHow to take more than one database value and save in a Combobox more than one returned value?
I have a question that is next, when I make a bank consultation he can return me more than two names, and I can only get one. The idea is to filter the names of doctors by the type of…
javaasked 7 years, 11 months ago Anderson Henrique 143 -
1
votes2
answers57
viewsAs in a Lerner, assigned to more than one Spinner, know who called him?
I am using 4 spinners in a single Activity and need to receive information from each Spinner. The point is that to use Spinner the "onItemSelected" method is used, and you must assign the value of a…
-
1
votes2
answers95
viewsValidate text before going to the screen
I got the following dataTable: <p:dataTable id="tabela" var="c" value="#{geracaomb.lista}" paginator="true" rows="10" rendered="#{not empty geracaomb.lista}" paginatorPosition="top">…
-
1
votes0
answers451
viewsWebview on android shows HTML
I’m developing an android app, which I use a webservice to pick up news from a website and play pro app. These news comes in HTML and I take a webview and I set the HTML to it, and it works…
-
1
votes0
answers126
viewsHow to make POST in android studio?
I’m trying to do a POST for my local API but I’m finding some problems and I’m not getting it right what I’m doing wrong. POST that works on Postman is with a body more or less like this: [ {…
-
1
votes1
answer48
viewsCardinality of MVC on desktop
What should be the cardinality of the desktop MVC? Models: typically one, there may be more. Views: how many are observing the model, or a tree, representing approximately the GUI? Vision should…
-
1
votes2
answers1767
viewsHow do I change the color of Alertdialog
I put it in my app where you can show the dialog to exit the application, but the dialog is black. I wanted it to be white. How do I change the theme of AlertDialog? @Override // SAIR DA APLICAÇÃO…
-
1
votes0
answers99
viewsI’m having second thoughts about how to do the leasing and return part
To do this, you must create classes: Item (available (Boolean), loan date, return date, name and code). Use the Calendar class to manage dates. Book (author and loan period - 14 days and should be…
javaasked 7 years, 10 months ago Almir Rogerio 11 -
1
votes1
answer117
viewsIs it possible to force a class to implement a Java attribute?
It is possible to force a class to implement an attribute in Java? I know that through interfaces you can force the class to implement methods, but I would like to do this with attributes as well.…
-
1
votes1
answer94
viewsWhy still use String instead of Stringbuilder in Java?
As many of you may already know, creating StringBuilder can greatly save the performance of our Java applications, as they are much faster than a String. This is due to the fact that the…
-
1
votes2
answers270
viewsUse a constructor with multiple parameters, or create multiple sets?
Amid use a constructor with multiple parameters or give a lot of sets, which of these options is more performative for the compiler, would cost less memory and would be faster?…
-
1
votes1
answer52
viewsJava Array: no value received
I’m having a little problem regarding a matrix I’m trying to develop to get coordinates inside a JFrame and pass them to position the buttons correctly. Follow the code: public class Coordenadas {…
-
1
votes1
answer69
viewsBlock Prints
The programme should: receive a 4 digit number, sort and keep, sort downward and save. Subtract increasing to decreasing and save so that the process starts again until subtraction equals 6174. I…
-
1
votes2
answers284
viewsScreen to configure Mysql connection
I am currently using the following code to run connections with my DB public class ConexaoDAO { public Connection getConexao() { try { return…
-
1
votes1
answer298
views"Unable to instantiate Activity" error while running Activity
My application has a home screen, where the user can select the registration screen. However, it is only me to put the gets that it stops working with this error below, does not show the…
-
1
votes1
answer218
viewsSimplest way to create circular array in Java
I’m looking for a more streamlined (clean code) way to create a circular array in Java. For example, given the following list: ArrayList<String> lista = new…
-
1
votes0
answers133
viewsHow to pass parameters for a query in a repository?
I’m creating a series of classes that return listings in Java (Android). I am concerned about the format of the parameters that will be passed. My initial approach has been to pass a Map with…
-
1
votes2
answers848
viewsWhat should be the communication between Model and View using MVC?
I’m trying to implement some small projects using the MVC standard: Within the project structure, I created the following packages: View : User Interaction Screens. Controller: I have a class with…
-
1
votes1
answer111
viewsHow to reverse the order of a sentence?
I tried to make a program that takes a phrase and returns the phrase in reverse order. Example: Input: "Hello, Java!"; Output: "Java! Hello,"; I tried to do it, but it’s not working. import…
-
1
votes1
answer33
viewsSearch in Elastic pass a list and return all matchs
I need to perform a search in Elastic search, but I’m having difficulties BoolQueryBuilder query = boolQuery() .must(matchQuery(CLIENT_ID, clientId)); fieldValues .forEach(fieldValue ->…
-
1
votes1
answer294
viewsJavafx Pagination
I was playing with Javafx and stopped when I wanted to add paging to my small application. I have a listview filled (as can be seen in the image), when I click on an item, its information is shown…
-
1
votes2
answers899
viewsApache POI - Error opening file generated in MS Excel
Hello, I’m running some tests with Apache POI, version 3.15, for reporting purposes .xlsx, using the example code below, only to generate a file: package exemplousoapachepoi; import java.io.*;…
-
1
votes1
answer19
viewsError trying to use AVG in @query Spring
When trying to perform a query to return the average score with spring null error appears. When I test without avg(a.note) it returns the data correctly. @Query(value = "select new…
-
1
votes1
answer100
viewsBest object-oriented way to solve the problem
Suppose I am modeling a Paycheck. However, each entry in a Paycheck I chose to model as a ItemContracheque. That is, to represent my Paycheck as a whole, I can use a simple list of ItemContracheque.…
-
1
votes2
answers235
viewsHow to use client certificate during server connection Handshake?
Hello! I’m trying to perform an authentication on a government server that uses digital certificate. To perform such authentication you need to import the SERPRO certificate strings referring to the…
-
1
votes2
answers96
viewsHow to stop a Quarkus application?
I can’t stop a Quarkus application. After starting a Quarkus application (quarkus.io) even after closing it with Ctrl+C (by command prompt) or clicking the Eclipse Stop button, it still stands.…
-
1
votes2
answers50
viewsRandom on button with isEmpty();
Hello, I’m new in programming to studying Java and now some Android. I’m trying to use the Random to send random messages if nothing is typed. So, my code is like this: public class MainActivity…
-
1
votes1
answer126
viewsInheritance problem with HIBERNATE
Well, my problem is this, I have an abstract class Official and two subclasses Attendant and Dentist inherited. I also have a class User, which has as attributes login, ... , .... , ... and an…
-
1
votes0
answers35
viewsUnitary test for filter application
I want to create a unitary test for the method: public BufferedImage negativo(BufferedImage image) { int width = image.getWidth(); int height = image.getHeight(); for (int i = 0; i < width; i++)…
-
1
votes0
answers101
viewsWhat is the correct way to register one to Many with DDD
I have studied DDD and assembled an architecture similar to the books and examples I have read. So far, when I’m gonna crud, when I record I run something like this: UI : The display layer fills an…
-
1
votes1
answer1423
viewsPick object id attribute selected in Jcombobox
I have a table in BD with Columns Id, Board N° and Drilling on board. I’d like to show on JComboBox the concatenation of "Plate N° + Drilling". Example: Plate 10 - 113,00 mm But when a combobox item…
-
1
votes1
answer61
viewsBackground problems
I’m having trouble filling my background with a specific color, in this case, blue. Follow the code of my application: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"…
-
1
votes1
answer468
viewsJava Runtime.getRuntime(). exec() Does not execute commands with space
I have a client socket and a server, the client sends a command to the server to run, but when the command has spaces, the server generates an exception: java.io.Ioexception: invalid null Character…
-
1
votes1
answer4117
viewsConvert ISO-8859-1 string to UTF-8 in java
My goal is to create a converter ISO-8859-1 for UTF-8. I already have this code: import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException;…
-
1
votes1
answer87
viewsFormat dates including offset
I’m not able to format in this pattern: 2020-10-01T11:34:00.270-03:00. SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS"); System.out.println(inputFormat.format(new…
-
1
votes1
answer228
viewsConstraint error while trying to persist with Cascade
Good morning, I have the following problem Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-01400: não é possível inserir NULL em ("XXGOVC"."ASSINATURA"."ID_DIRETRIZ") And here is…
-
1
votes1
answer173
viewsWhy can’t I access the elements inside an Arraylist with a for?
I’m trying to fill a jtable with elements that are inside an arraylist, which is inside another object: private void jButtonConfirmarProdutoActionPerformed(java.awt.event.ActionEvent evt) {…