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
answer75
viewsTransform View into Bitmap without using buildDrawingCache()
I have a function that takes a view and creates a bitmap. follow the code: public static Bitmap getBitmapFromView(Context context, View view) { DisplayMetrics displayMetrics = new DisplayMetrics();…
-
1
votes1
answer277
viewsCannot change version Facet Dynamic Web Module to 4.0. Maven
I had this problem and I thought I had solved it, but when I opened eclipse hj the problem just happened again, the strange thing is that it only occurs inside the IDE, because if I compile and put…
-
1
votes1
answer57
viewsSend gps location to a server
I have a service to get the user’s location, but I need to pass the latitude and longitude via request to a server, however I tried to make this request within the method onLocationChanged() using…
-
1
votes0
answers39
views15 Puzzle A* Some cases do not work
I’m trying to implement the A Star algorithm to solve the 15-puzzle problem however there are some that run for infinite time without solving the problem. for example the input(the top one is the…
-
1
votes1
answer39
viewsTransmission error socket c#
I have the following code: public void StartListening() { try { btEngine = new Engine(true); IPAddress ip = IPAddress.Parse(txtServer.Text); IPEndPoint localEndPoint = new IPEndPoint(ip, 5000);…
-
1
votes2
answers520
viewsCreate . jar of a multi-package project, without IDE and on the command line
When doing a search for the websites of Stack Overflow, I realized that all topics only teach how to create the file . jar of a single class or even teach how to create the . jar of an entire…
-
1
votes1
answer291
viewsStatement or Preparedstatement, for what reason avoid using Statement
What problems can happen if I use Statement instead of Preparedstatement on the JDBC connection to the database //Code using Preparedstatement, setting query values through methods Connection con =…
-
1
votes2
answers114
viewsImageview Visible with onClick becoming invisible again?
Talk to you guys, I have an Image that starts invisible and when clicking the button it becomes visible, but I need it to be invisible again because when clicking the button again, it has to appear…
-
1
votes0
answers19
viewsHow do I use KEYLISTENER while a THREAD occurs in the execution? With the code below only the thread acts
import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; public class Letras extends Frame implements Runnable,KeyListener{ private final Label pontuacao;…
javaasked 5 years, 6 months ago Heleoterio Gomes 11 -
1
votes1
answer159
viewsManipulating divisible 3 and 5
I have a statement that says I have to make a looping between 4 and 24, adding the index with a total value, with some points: If the index number is multiple of 5, it must add up to 3; If the index…
-
1
votes0
answers121
viewsHow to create a Generic method that takes any entity class, and starts a session in Hibernate?
Good night, I am trying to create a method that receives any entity class and an ID to start a session on Hibernate. The idea is to make a Generic DAO to take only the ID of the entities I want.…
-
1
votes2
answers248
viewsreturn a part of the code in java
System.out.println("digite Lançar para Rolar os dados para atirar no homem"); P1_rolar = L.next(); long P1_dado1 = (long) (Math.random() * 20); if (P1_dado1 < 21) { System.out.print("seu…
javaasked 5 years, 6 months ago zDarkSword 11 -
1
votes2
answers874
viewsJava: create Inner Join using criteria
I’m having a hard time finding good examples of how to create a query criteria using Inner Join. I created the query below that would be what I would like to do with the criteria. SELECT DISTINCT *…
-
1
votes2
answers160
viewsHow to change the size of an Edittext contained in a Alertdialog?
I have a problem, inside a Alertdialog there is an Edittext, but it always gets very big and very close to the margins, I want to make it smaller and centered in the middle of Alertdialog, I tried…
-
1
votes0
answers36
viewsApp hangs after clicking button
I have to perform validation of the fields and create the calculation method to tell which is the best fuel, however, when pressing the button, the application hangs. I can’t identify where the…
-
1
votes1
answer32
viewsHow to randomly rearrange a list of Strings and select one element at a time without repeating the value contained in the list?
I am developing an application in Android studio in Java language and need to know how to solve my problem. I have a list of String: List<String> valores = new ArrayList<>(); Then I…
-
1
votes1
answer313
viewsJava program to insert lower and upper bound and return the sum of even numbers from the range
I’m having trouble getting this code to work properly. The goal is to sum all the even numbers of a given range (upper and lower limit), but is not returning the correct result using the for. For…
javaasked 5 years, 6 months ago Matheus Portugal 13 -
1
votes1
answer514
viewsHow to use Spring Data Binding Object for Snake case attributes while maintaining the Java Naming Conventions standard?
Hello, is there any way to perform Binding date of objects in Spring using Snake case? For example, suppose the following request GET on a job REST: http://localhost:8080/Foobar? foo_bar=example For…
-
1
votes2
answers85
viewsJPA Hibernate with Postgres - 2 transactions
I started using Hibernate 1 month ago. I am developing a simple application from bank to college. I have an account class, which has the Withdraw Value method : public boolean SacarValor(long…
-
1
votes0
answers30
viewsCast problem in onAttach method
I am making an application that creates graphs, I am creating the implementing of the nodes via Dialog where the usurious selects us and creates a arrest but this giving Cast error. public class…
-
1
votes1
answer111
viewsApplication error using vector java.lang.Nullpointerexception
Good morning. I’m trying to perform a proposed exercise in a Java course that I’m doing but I’m not getting it. This is a simple program that simulates the reservation of a hostel using vectors. I…
-
1
votes2
answers688
viewsHow to load a Selectonemenu based on Select Previous using JSF?
I am trying to register a Neighborhood based in the City and the selected state. The list of the city depends on the state selected. Follows my code: <div class="form-group">…
-
1
votes1
answer62
viewsSet time variable on Back button
You guys, good night. I need a little help, I have the following code. Because I need to stop Thread when the back button is clicked. private void timeGame() { t = new Timer();…
-
1
votes1
answer340
viewsHow to insert a date into an SQL and Java tuple
I tried to insert a date into a tuple in SQL but I couldn’t, using the Calendar.getInstance() I can only get the current date, but I want to choose another date to add. public class Prova { private…
-
1
votes1
answer878
viewsInternal Storage - open failed: ENOENT (No such file or directory)
I have a problem that I haven’t been able to solve for a few days. I have a list of files that are saved in Internal Storage and what you need to do is zip those files when users leave the activity.…
-
1
votes0
answers126
viewsMonitoring events from a particular directory
Hello, I am developing an application that monitors events (create, delete and modify files) of a given directory. I’m using the apache.commons.io.monitor library to assist me. Generating the one .…
-
1
votes0
answers72
viewshow to take specific values through hashmap
Guys, I have this code. What he does: it serves to count how many seconds it takes me to type a sentence, in this case, 'technology'. However, as the intention is to imitate a keyboard, this…
-
1
votes2
answers94
viewsIncorrect Output when Printing Array Elements
public class Principal { public static void main(String[] args) { Turma turma = new Turma("Est. de dados","A1","20191"); turma.inserirAluno(new Aluno("Anselmo",111)); turma.inserirAluno(new…
-
1
votes1
answer125
viewsNumberformatexception: Invalid int: "1" I CAN’T CONVERT STRING TO INTEGER
I have a String = "1" and I can’t convert it to int, I think it might have something to do with the way it was built, the class that reads the TXT file from the web and saves it in the database is…
-
1
votes1
answer47
viewsFalling in catch while trying to establish a connection
I’m using Netbeans and can’t establish a connection. I added . postgre jar (postgresql-42.2.5.jar) in the lib folder and tested the connection in the Netbeans tab (Service > database), ok worked.…
-
1
votes1
answer122
viewsThe Annotation @Persistencecontext is disallowed for this Location
I’m getting the message "The Annotation @Persistencecontext is disallowed for this Location" when I try to put this annotation in the code, someone knows how I can fix it? @Stateless public class…
-
1
votes0
answers32
viewsHow to deal with Scala x Java classcasting
I’m having a problem working with heritage between Scala and Java. To contextualize, follow an example that reflects my problem. Java Class public class Animal { } Java Class public class Cat…
-
1
votes1
answer78
viewsHow to iterate inside a list that is inside another class?
I wonder if it is possible to iterate a list that is in another class. On a social network, every user has a list of posts, but this list is defined only in the class User how to iterate inside it ?…
-
1
votes2
answers3560
viewsHow to fix the error: cannot deserialize from Object value (no delegate- or Property-based Creator) using Spring Boot?
I am trying to send a JSON to my Spring method for entry into the database but I get the following message: JSON parse error: Cannot construct instance of br.com.marketHubServer.model.Collaborator…
-
1
votes1
answer489
viewsBiometrics on Android
Hello, everyone from Stackoverflow. I’m a beginner in Android development, and I just developed an application, now I want to improve it, putting as input into the same biometric system, so that has…
-
1
votes0
answers75
viewsChanging the parameter of a java method
I am developing a code that uses ECC encryption. I am using the following code: import java.security.*; import java.security.spec.*; public class Teste { public static void main(String[] args) {…
-
1
votes1
answer125
viewsDocker-Compose Tomcat - mapping external directory
I have an application running on Tomcat where when I upload an image, it saves in "portal/WEB-INF/classes/Static/img" which is a directory within my application. The problem is that when I update…
-
1
votes1
answer54
viewsIs there a Java method equivalent to C#’s Padright()?
I need to fill a string with blanks if I don’t use all the space. In C#, briefly I do as follows: Console.WriteLine("-----------------------------------------------------------------------");…
javaasked 5 years, 5 months ago Ramon Almeida 382 -
1
votes1
answer53
viewsHow to start an audio automatically on startup of a Java application?
I am having difficulty starting this application along with an audio "Mixx.mp3". I have no errors, but the sound does not play. public class MostrarLuta { URL som =…
-
1
votes1
answer387
viewsHow do I filter a search using Searchview?
I’m building an app where in a particular app a list of registered users will appear in a ListView. This Activity also has a SearchView which serves to filter data from ListView according to the…
-
1
votes2
answers102
viewsList something from a constructor
I have a code in Java that creates a client in the class Cliente: public class Cliente { String nomeCompleto; String dataNas; String email; String senha; } then I have the builder of this Cliente…
-
1
votes1
answer351
viewsHow to start a process in spring-boot after injecting all the Beans and before you start listening to external events?
I am creating an application in Spring-Boot that for me is critical she recover her previous processing point before to start receiving new requests. For such, I have a table called PROCESSOS which…
-
1
votes1
answer56
viewsHow to take a value from a Static method
good night. I’m implementing a code that stores the amount of comparisons and the sorting time of binary search. So, I’m storing the data in a text file for later analysis. It’s just that I have a…
javaasked 5 years, 5 months ago Luiz Gustavo 47 -
1
votes1
answer247
viewsCould not find method connectionBanco(View) in a Parent or Ancestor Context for android:onClick attribute defined on view class
package com.projeto.comandapack; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.EditText;…
-
1
votes2
answers511
viewsJava IMC, helps with an error
What’s wrong with that code, I can’t print the IMC calculation? Error is in the last lines of the Person Class. package exe_3_ques_02; //import import java.util.Set; import class…
-
1
votes1
answer312
viewsTake the value of a dynamic span element
I need to get an id value of a dynamic span and I’m not getting it. What I’m doing wrong? Error: There was an Unexpected error (type=Bad Request, status=400). Required Long Parameter 'id' is not…
-
1
votes1
answer158
viewsInsert object from a Linkedlist to a Linkedlist from another class
I have two classes in my project: Cars and Cars. At first, I have a Linkedlist stated as follows: private LinkedList<Carro> carros = new LinkedList<Carro>(); Then I have methods of…
-
1
votes1
answer104
viewsAjax request responding with status 500
I am using Spring, I test the return in the service and controller methods and are correctly returning what I want, and is entered in the database, but even so gives the error: My request:…
-
1
votes1
answer493
viewsStoring questions from a java quiz
I have a quiz game made in java and would like to add in a class the questions that would appear on the screen for the user, I thought to use Arrylist, but it is not working. I tried that: package…
-
1
votes1
answer69
viewsI am starting in java and am having the error java.lang.Nullpointerexception
ERROR: Exception in thread "main" java.lang.NullPointerException at br.com.drogaria.dao.FabricanteDAO.excluir(FabricanteDAO.java:33) at br.com.drogaria.dao.FabricanteDAO.main(FabricanteDAO.java:64)…