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
votes0
answers366
viewsjavax.faces.Validator.BeanValidator.MESSAGE={1} {0}
I created a form where I have the following Name, Job, Login and Password fields. I’m using the javax.faces.validator.BeanValidator.MESSAGE={1} {0} to returns error message to the user. I know it is…
-
1
votes1
answer533
viewsLinkedlist in Java
First of all, I have a Linkedlist called Linkedeventos. LinkedList<Eventos> LinkedEventos = new LinkedList<Eventos>(); Then I have an assignment LinkedEventos = Compra;. Someone can tell…
-
1
votes1
answer1179
viewsHow do I sort string in the Insertion Sort method?
I’m with the following method, but in the WHILE line it’s error. netbeans says "bad operand types for Binary Operator "&&", first type: Boolean, Second type: int". public boolean…
-
1
votes1
answer2149
viewsAlgorithm problems for calculating NPV and IRR
I have a logic problem to calculate NPV and IRR. Formula for the NPV: Formula for the IRR: From these formulas I arrived at the following method: public double[] calcularVPLTIR () {…
-
1
votes0
answers83
viewsSave IP server data
Good morning people when trying to connect to a server I set up my firewall and configured the files pg.conf and pg_hb.conf to allow remote connections but presents this error could help me ? it…
-
1
votes2
answers1959
viewsCall Stored Procedure with JPA 2.0
I need to call the following process below, only the company’s projects use JPA 2.0 and all the examples I find are for JPA 2.1 +. prc_performance_vendas_obter(vdataini => :vdataini, vdatafim…
-
1
votes1
answer81
viewsBinario to Hex
I am developing a server that accepts connections via socket. But the information received is in binary and during printing appear strange characters. I believe that the conversion or the way I read…
-
1
votes1
answer684
viewsHow to transform an array from one dimension to two in Java?
I have an array of one-dimensional integers, like this: int[] a = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; And I want to turn it into a two-dimensional array, for example: [1, 2, 3], [4, 5,…
-
1
votes2
answers1793
viewsOnly get the first name, after space using Java
Good afternoon. I got the following String: "Carlos Ferreira da Silva" I wanted to take just the first name and ignore rest after the "space". Using regular expressions, how could I do that?…
-
1
votes1
answer1228
viewsNullpointerexception error when running java Maven project
I created a Maven Java Application project and only created a layout of a screen. When I try to run, it shows the error of NullPointer, I have not yet implemented any code other than the IDE’s own.…
-
1
votes2
answers159
viewsModular programming in Java, called methods
He needed help to put the smaller and larger method to be "heard" in the main method. The logic of the program is to show the user what is the highest and lowest value of a vector. CODE: import…
-
1
votes1
answer72
viewsHow to get Email after Login to Facebook using Spring for Android Sample?
I’m using the Spring for Android Sample framework. The facebookProfile.getEmail() method does not display any information, the other methods, facebookProfile.getId() and getName() work perfectly.…
-
1
votes3
answers2915
viewsHow to access a private attribute of a class in another class?
I created a chat in Java. In the class Servidor, the user passes as input the port on which the server will run. In order for the chat to work correctly, I need to access this class variable…
-
1
votes0
answers80
viewsJava SOAP Web Service error in Glassfish
I have the following method in a SOAP Web Service running through Glassfish 4.1.1: @WebService(serviceName = "CalculatorWS") @Stateless() public class CalculatorWS { @WebMethod(operationName =…
-
1
votes0
answers93
viewsI cannot delete my object in datatable - JSF
I am unable to delete an object in my datatable. NOTE: I can already persisistir and change. My Bean package com.irmaosuspension.controleservico.controller; import java.io.Serializable; import…
-
1
votes2
answers701
viewsIn Netbeans it works, not in Jar
I know you have some similar topics, but none of them answer my question. I created a program to insert information into the database and it works perfectly when I have netbeans compile. I made the…
-
1
votes0
answers42
viewsServlet configured with annotations not loaded
I have the following class: public class SpringServlet extends AbstractAnnotationConfigDispatcherServletInitializer{ @Override protected Class<?>[] getRootConfigClasses() { return new…
-
1
votes0
answers118
viewsError 404 in spring
Man jsp <form method="POST" action="/desif/titulo/salvar/"> <div class="form-group has-info"> <label for="codigo" class="col-xs-12 col-sm-3 control-label no-padding-right"><font…
-
1
votes2
answers128
viewsJava: Connection Class Error
How to fix this error ? This is preventing you from connecting to the bank.... private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // Eventoos do Botao inserir try { //Registra…
-
1
votes1
answer180
viewsHow to create getter from Local Date variable?
I have a class called Hospede, where I have the method getData_entrada(), that returns a variable LocalDate(new java8 API). However, when I try to capture this method, it always returns to me…
-
1
votes1
answer1103
viewsWhat is the difference between Error and Exception?
Why we have Exceptions (IOException, for example) and Errors (OutOfMemoryError, for example)? I know you both inherit from the class Throwable, but what’s the difference between them?…
-
1
votes0
answers103
viewsHow do I connect to a user-selected SSID?
I’m doing my thesis and I’m developing an Android app to set up home devices Iot (wifi). In this case, the devices are being simulated using a Rspberry Pi 3, which creates an access point (captive…
-
1
votes1
answer216
viewsJpa does not create column @lob
I’m mapping a field @lob to save image to a table, but jpa creates the table, but does not create the column. I created the column manually in MYSQL, but then the bytes do not persist either. My…
-
1
votes2
answers1825
viewsDoubts how to leave a unique attribute - JPA
I am creating an entity, and I have a CPF field and this field that is unique, how to map this CPF field? My entity. @Entity public class Client { @Id @GeneratedValue(strategy =…
-
1
votes1
answer191
viewsDoubts with Crud java CDI
I have connection with some database, with that, I made a class called connection, where I have verification of which database to use: package DAO; import CDI.Corporativo; import CDI.Java3DS; import…
-
1
votes0
answers71
viewsClose an Activity and start another (Intersticial admob)
I have an Interstitial admob on an Activity and when I press a button I put the following lines of code: botaoid.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v)…
-
1
votes1
answer363
viewsHow to set Rendered parameter via JSF bean 2
am facing a small challenge where I need to create a Dashboard dynamically from a drop down. It is functional but there is a button in each Panel that the rendering of it depends on the existence of…
-
1
votes0
answers23
viewsCompare Year and Count Registered in Bank
I wanted to count registered clients in my bank, born in the year 1930 until the current year (2017). In my bank I have registered as date, date of birth ex: 2000-10-01 So I wanted to make one for…
-
1
votes0
answers29
viewsPossible lock in file creation
Hello folks I am testing a java system that generates forms in excel but on the server it is it works smoothly generates the report but when I share the folder and try to access from elsewhere…
-
1
votes1
answer112
viewsCloning a class
I am "trying" to clone the following class: public class CadHorario implements Serializable, Cloneable { private int cdHorario; ... private Date horarioInicio; private Date horarioFim; private…
-
1
votes1
answer133
viewsClient Encryption / Server / File / Obfuscator
Hello, I’m creating a Java game using Libgdx, but I want to know some things. What is the best encryption for communication between Client / Server (for no one to intercept the package I send) What…
-
1
votes0
answers104
viewsShow Fragment in Activity with Transition
Good afternoon, I have a main Activity with a button and I would like that when the person clicked this button this Fragment opened on the screen, are three buttons within a linear layout.…
-
1
votes2
answers86
viewsCapture list item by index
I have the code: for(int i = 0; i < 99999; i++) { minhaLista.get(i + x); //x é int e possui um valor qualquer } At some point the sum of i + x results in a value greater than the list size. If…
-
1
votes2
answers325
viewsMatch more than one condition in a junior
Is it possible to combine more than one condition in the first one? Example: boolean existe = pessoa tem 23 ou pessoa tem 22 ? true : false ; I’m trying but I can’t.…
-
1
votes0
answers51
viewsFile directory
Hello, I am making a program in java in which I need to open a file and read it. However when I am trying to put the file path, it does not find such file and so I get Null Pointer Exception error.…
-
1
votes1
answer450
viewsIs it possible to dynamically instantiate Arraylist in java?
For example, if I need to create arraylists for each person q register in my system: ArrayList pessoa1 ArrayList(); ArrayList pessoa2 ArrayList(); ArrayList pessoa3 ArrayList(); The problem is I…
-
1
votes1
answer315
viewsDoubt on how to use Shift in Java
Well, I have a question about how to use Shift Left in java. I have a String representing a hexadecimal value. Only I need to pass this value to binary. For this I use an integer variable to turn…
-
1
votes1
answer1111
viewsSave object with uppercase vs lowercase letter
I think I had posted a question previously equal to this, but I did not find. I have a Manufacturer entity where I want to persist, to avoid differentiating between upper and lower case letters, can…
-
1
votes2
answers1055
viewsJPA spring boot custom data does not work
public interface ProdutoRepositorio extends JpaRepository<Produto, Long> { @Query(value="SELECT new br.com.thiago.objcustom.SomaDosProdutos(e.nome, sum(preco)) FROM sitethiagodois.produto p…
-
1
votes1
answer787
viewsSystem.setProperty - Set path to chromedriver
I’m starting to mess with tests using Lenium and Junit. I need to set the chromedriver.exe path. I wonder if you can leave chromedriver.exe inside the project folder and set the path in a way that…
-
1
votes2
answers73
viewsCreating a Mysql default date string from a Java Date
I need to pass a string in this format: "yyyy-mm-dd+HH:mm:ss" (where "+" should be a space) to a webservice from a Java Date object. How can I do that?
-
1
votes2
answers77
viewsApplication is returning Nullpointerexception error although the object is set
Error while clicking save the new process after assigning the data in each field: java.lang.NullPointerException: Attempt to invoke virtual method 'long…
-
1
votes1
answer150
viewsQuestion about updating Jlabel in Jframe
Why can’t I update my labelHora in the Frame? Using a print after the line labelHora.setText(x); I realized that the content of lip changes, but on the screen continues the pattern, which in the…
-
1
votes1
answer142
viewsProblem passing information on my login
am receiving this Exception at the time of logging in ERROR [org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter] (default task-10) An internal error occurred while…
-
1
votes0
answers472
viewsI can’t update jFrame from a Java thread
I have a code that reads the Serial Port through a thread, but when I try to update a label I can’t. I implemented a Serialread Runnable class, and in this class I run a loop to read the serial…
-
1
votes2
answers137
viewsPrevent classes from changing the state of objects
How to prevent classes from modifying the object state of a class, both Within equal and separate packages? Assuming there is a Pattern to design a java class design that can or even affects the…
-
1
votes1
answer55
viewsProgrammatically set button text color
I have a button created in my class Main via code, that is, programmatically. See: Button btnJonSnow = new Button(this); btnJonSnow.setText("Jon Snow"); How can I program the color of the button…
-
1
votes1
answer103
viewsReactive Native error when generating Android app
I’m running the commands: react-native init AwesomeProject cd AwesomeProject react-native start And then that command: react-native run-android The error that appears: How to correct this error ??…
-
1
votes1
answer584
viewsAfter requesting AJAX input no arrow value to Managedbean?
I’m building an address registration form and implemented the State and City combos respectively. They work as usual, with the city combo being filled in according to the value selected by the state…
-
1
votes0
answers143
viewsDoubt monitoring Tomcat with Java Visualvm
Inside my jdk Bin folder I downloaded the "jvisualvm.exe", it is not in the machine environment variables, more after that I configured Tomcat 8: -Dcom.sun.management.jmxremote.port=8086…