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
answer352
viewsError trying to insert data to Postgresql
I’m having trouble entering information to the BD. I believe the error is in the DAO layer more specifically in the insert function. You could help me find this mistake? CONNECTIONFACTORY package…
-
1
votes2
answers1752
viewsHow to verify if user has already been registered in the database?
How can I check if user is already registered? For example, when registering a user check if the login has already been saved in the BD. DAO was like this: public boolean validarLogin (String login)…
-
1
votes1
answer51
viewsJava array shows specific items
Hello, guys I’m having a doubt for example I have Array A {1,2,3,4,5} I do another array B {1,2,3} with the items I wish to exclude from array A, and show the items that were left ex 4 and 5 , but…
-
1
votes1
answer145
viewsAm I throwing correctly?
I’m doing like a Firebase DAO that performs and handles Auth, Database and Storage. But Firebase emits some exceptions depending on the scenario, password with less than 6 digits, email already…
-
1
votes1
answer59
viewsSqlgrammarexception
Good night! Someone can help me with the error in my code, I followed the teacher’s steps but presents error in mine and not in his example. I am using the same dependencies. Follow the method…
-
1
votes0
answers95
viewsProblem persisting in SPRING-DATA/JPA using Composite Key / Does not return Generated Id
Hello someone already had this problem, when saving a class with composite key, the Spring Data API does not return with the generated id? I ran a test with primitive classes with unique id so it…
-
1
votes1
answer117
viewsJPA - There is the possibility of using Matchmode.ANYWHERE with Predicate
Usually when I need to do a search picking up a result through a single word, using Criteria and Restrictions I do as follows: criteria.add(Restrictions.ilike("nome", filtro.getNome(),…
-
1
votes2
answers2112
viewsMascara for money on android
I am creating a function for when the user type in a EditText , he returns me with a masca in the field, Example: Typing 1 returns "R$ 0.01" When typing 11 returns "R$ 0.11" and so on and so forth I…
-
1
votes1
answer104
viewsPull back from Asynctask class
I have a class Main that performs a method receberSolicitantes() with a task in background. While it is executed, it updates a progressBar. Everything is working perfectly with the method as…
-
1
votes2
answers102
viewsHow to use the Sharedpreferencesutils.java class?
Sorry about the title, I don’t know how else would be a better way to ask. I’m learning to code on android apps, and I found a JAVA class to facilitate the use of Sharedpreferences. But I don’t…
-
1
votes2
answers117
viewsValues do not serialize in return in REST with Jersey
Good morning, you guys, I’m new here and beginner also with Java and I’m having a problem with the serialization of an object and no longer know what to do. I am giving, at least trying, to maintain…
-
1
votes1
answer470
viewsProblems with Jars
I have a Spring application that uses Maven. All the dependencies are in the file pom.xml or the Jars are in my repository .m2 local. Every time I try to run the application the following messages…
-
1
votes2
answers91
viewsHelp with String algorithm
I need to make a program in which the user types a string and a subletter, and inform how often this subletter occurs in the main string. Ex: Main chain: "banana" Subdivision: "na" Repetitions: 2.…
-
1
votes0
answers498
viewsHow to call another screen through the Menuitem
I’m trying to call another screen (include) through a Menuitem, but it’s not working. At first, I can call my Login screen from Main.java, then tbm can log in and call the Menu screen via a button.…
-
1
votes1
answer209
viewsExport Sqlite Android Database
I need to export my database Sqlite to a folder on the device on which it will be installed, and every time I open the application, the file ". bd" be updated so that at the end of the month I can…
-
1
votes0
answers1123
viewsSend JSON Javascript post method
I have a Restful API written in Java, which has implemented GET and POST methods, tested the methods with the Postman application and are working. Follows the class Filter @Override public void…
-
1
votes1
answer188
viewsRename worksheet tab
I’m having trouble renaming an Excell file tab. I’m debugging and after it gives the set the new name.. i can see the new name changed in the execution but in practice the file itself is not…
-
1
votes2
answers1025
viewsHow to download a compressed file from a URL and save to disk?
I made a java program to download a compressed (zip) file from a server from a URL (in this case, I am using localhost to test), but it is giving the following error: Exception in thread "main"…
-
1
votes1
answer576
viewsError 404 apache Tomcat
I am new to web services, however lately I have taken to develop mine, however I can’t even do a hello world due to an error that Tomcat is returning me, it just doesn’t find the URL, can help me?…
-
1
votes2
answers1711
viewsRequired field, fill in before saving
I’m trying to validate the fields so it’s mandatory before saving the data. Follows the code protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);…
-
1
votes1
answer123
viewsChanging the xml by java
I was wondering if there’s a way I could change the layout="@layout/app_bar_main" of <include> by java <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout…
-
1
votes1
answer131
viewsAlarmmanager is not repeating
I have an alarm that is triggered every 5 minutes, and it calls an intentService to test a condition that if true, sends notification to the user, otherwise he does nothing. But the intentService is…
-
1
votes0
answers39
viewsQuartz Spring Test Junit
How to recur a Job that is operating in Cluster in Spring? Spring 4.3 Quartz 2.2.3 Example of Job’s declaration @PersistJobDataAfterExecution @DisallowConcurrentExecution public class…
-
1
votes2
answers362
viewsPOO JAVA - Doubt Exercise
Good first follows down the exercise: Create a class called Date including three parts of information as instance variables: one mês (tipo int), one dia (tipo int) and a ano (tipo int). Provide a…
-
1
votes1
answer178
viewsSending data via sockets(): :Software caused Connection abort: socket write error
I have a client server program that is working when I request the communication but when it starts sending data the program generates the following error: Estabelecar conexão....... Conexão…
-
1
votes1
answer447
viewsDoubt about the price calculation
My doubt may seem simple to someone, but to me it’s kind of killing me because I’m trying to find the mistake and I’m not getting it. At first, I know very little about object-oriented programming…
-
1
votes1
answer45
views"Column 'Value' in found." when fetching balance in query
I’m building an ATM simulator, with the features of Deposit, Withdraw and Extract are functional. However, I’m not getting the balance. I have the method emitirSaldo() which must receive the value…
-
1
votes0
answers20
viewsJasperserverrestclient
Good evening I am using Jasperserverrestclient to retrieve a report from Jasper server, but when I try to use Reportexecutiondescriptor it is null. Could someone help me? RestClientConfiguration…
-
1
votes0
answers97
viewsDAO not injecting with @EJB Annotation
I’m making a requisition for "/counter/{id}" by Postman and when the code arrives in notifiedAAO.counter(id), I get the error message saying that notifiedDAO is null. PS: I’m using Wildfly 11 with…
-
1
votes1
answer418
viewsFrom Json Object to Listview
Good afternoon to all, I have two classes, the bemVindo and the one that receives data in json and stores in an object and after the json data is received the class sends to the bemVindothe data…
-
1
votes1
answer339
viewsRecover shopping cart after close and open browser
I’m assembling a shopping cart with JSF it’s working, but not in the way I believe is correct. Example: When I enter sales sites, even if I am not logged in, I can add items to the cart, and even…
-
1
votes1
answer320
viewsWhy pass arguments to a Fragment using Bundle instead of a set method
I recently asked myself a question, seemingly simple, that I could not answer and I did not find any concise answer. The question is simple: Why use Bundle instead of a set method to pass parameters…
-
1
votes1
answer563
viewsRun simultaneous java threads with parameters, run method
I have a service today that I need to calculate its running time with multiple accesses, so I’m trying to run simultaneous threads and log that time, the problem is that for the run method of the…
-
1
votes1
answer176
viewsProblems with spring mvc friendly url
by including a last page in my project I got a url problem, from which, I could not identify the problem. JSF scenario: Certification module: href="customer service/" Customer details:…
-
1
votes2
answers433
viewsPut a name depending on the array number
Let’s say I have four variables: - Porto = 1 - Benfica = 2 - Sporting = 3 - Braga = 4 I have this code that makes me a shuffle of numbers of an array called "arr". Integer[] arr = {1,2,3,4};…
-
1
votes0
answers182
viewsUnit Testing - How to test a Try-with-Resources?
I would like to know the best way - or the standard way - to test a Try-with-Resources; with Test Cases for each of the Exceptions that can be launched (simulating the release of each of these…
-
1
votes3
answers1344
viewsConvert String to double in Java
I am reading data from an external file with CSV format. However this data is coming in CSV format String. There is a price field that I need to turn into double for handling purposes. Class…
-
1
votes1
answer754
viewsShow output from a JSP page Servlet list
I need to capture an input name, query the database and return the result on a jsp page. I want to show the result in a short snippet of the JSP page, in case I mix the text of the JSP page with the…
-
1
votes3
answers106
viewsFind the size of the largest sequence of # in an array. JAVA
I’m new to Java and found this problem: Given a character array ('.' or '#'), your task is to specify the the size of the largest contiguous segment (horizontal or vertical) of characters '#' This…
-
1
votes1
answer901
viewsHow to set values for an array attribute?
I have a java class representing an entity snack,follows below the class: public class Lanche { private String nome; private int id; private double preco; private String[] ingredientes; /*getters…
-
1
votes1
answer66
viewsProblem sending arrays from one method to another using Thread in Java
I’m doing a program that simulates sending a message from the physical layer to another physical layer of the OSI (ISO reference) model of networks. My code has a method that sends "frames"…
-
1
votes1
answer1968
viewsHow to return a table, from a POSTGRES Function?
Hello, I’m trying to create a function in postgres, which at first is all correct, taking the return of function. When I run the function, it is returning all lines, but all only in a field as a…
-
1
votes1
answer517
viewsError No suitable driver found while connecting with javaDB
I created a database using the javadb netbeans derby, then created a connection on port 1527 with the name of the Database being TEST. After that, I created the connection string below that should…
-
1
votes1
answer2832
viewsHigher and lower value
Make a program that takes a set of integer and positive values and calculates and shows the highest and lowest value of the set. (To close the input, zero must be entered). I know that the part of…
-
1
votes1
answer606
viewsHow to change the focus between tabs on a Jtabbedpane?
I am trying to do the following routine. On my "main" screen, I own a JTabbedPane with two tabs, in which the focus is on the first tab. I need to open one JInernalFrame and, by closing it, make the…
-
1
votes2
answers61
viewsRelationship problems @Manytomany
Good afternoon Personal I’m having trouble in a relationship @ManyToMany. I have the class Equipamento and have the class Fornecedor, where I can have a supplier who has various equipment and where…
-
1
votes2
answers132
viewsDo I really need to start from a main to run a Schedule in java?
I am developing a web application, and now I have reached a point where I will have a process running in parallel in my application(in background) every day at a time x. To test the process, I made…
-
1
votes1
answer64
viewsUse of repeat loop appropriately
"A very common joke among 3 friends is the game of 2 or 1. In this game, the winner is different from the other two and, if the three choose equal values, the game ends tied. So consider three…
-
1
votes0
answers706
viewsHow to pass an object to another Activity
public class Despesa { private long id ; private Date data; private String local; private String endereco ; private String cnpj ; private LinkedList <Item> itens; private String URL ; public…
-
1
votes2
answers112
viewsCapture the moment the mobile screen was lit and when it was deleted
Hello ! I’m building a project similar to an alarm clock but I’m having a hard time trying to use the broadcastreceiver class. Problem: I want to capture the date and the exact time that the mobile…