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
answers1186
viewsExtract JDBC Connection from Entitymanager using JTA
In an environment Javaee, there is the possibility to extract the JDBC connection(java.sql.Connection) using JTA? I have a datasource in Wildfly, where I inject in the following way:…
-
2
votes0
answers280
viewsManytomany Hibernate error
Hello, I have a relationship @ManyToMany bidirectional between the class Pessoa and Endereço, where for these, I have the tables in the bank for person, address and the table for the relationship…
-
2
votes0
answers548
viewsJAR Executable much slower than running by Netbeans
Good morning, I have a project in netbeans that uses Maven to build an executable jar, so far so good. The problem is that when I run the project by ". jar" that is generated by Maven, execution…
-
2
votes1
answer88
views -
2
votes2
answers786
viewsHigh demand stock control with Firebird and/or mongodb
I’m thinking of migrating my ERP (currently in java) from a relational database (currently in Firebird) to a Nosql (probably Mongodb). I am planning and trying to anticipate the possible problems.…
-
2
votes2
answers458
viewsSort a java List containing null values
Good morning! In my List, when I do the ordering I would like the null values to be last. I’ll show you an example to make it clear: Code output (in this case the word would be the letter after the…
java list arraylist comparison collectionasked 6 years, 10 months ago Carlos Rafael de Oliveira Carn 50 -
2
votes1
answer197
viewsWhat does Java memory management accomplish in an assignment of a previously allocated variable in memory?
I would like to better understand what Java memory management does in the following situation. Knowing that I am suffering from performance problems, I am trying to take the utmost care not to make…
-
2
votes2
answers266
viewsSelect returning dates in the object other than what is registered in the Mysql database
I have a problem when I list the contents of a table and store in a list the date is one day less. I’ve done a lot of research on the web and can’t find a solution to the problem. Below the method…
-
2
votes2
answers198
viewsHow do select in specific columns and continue to receive an entity list and not an Object array?
Having the second class: public class Usuario { private Integer id; private Email email; private String nome; private String sobrenome; private String senha; private String usuario; private…
-
2
votes0
answers1149
viewsCould not read Entity state from Resultset Entitykey Onetomany composite keys
I’m having trouble in oneToMany relationship of two entities using Jpa Hibernate. I have two tables, one for cancellation and another that has the orders that are part of the cancellation. The…
-
2
votes1
answer61
viewsWhat’s wrong with these hash algorithms?
I’ve researched several hash algorithms, and found some examples on Soen, but they’re returning different hashes to the same file: import java.io.File; import java.io.FileInputStream; import…
-
2
votes1
answer475
viewsError javax.naming.Noinitialcontextexception - console application
I’m trying to make a simple EJB, followed some tutorials, analyzed the Wildfly sample code, and yet, I’m facing an error. Could someone help me? The mistake:…
-
2
votes2
answers12692
viewsError Creating bean with name 'entityManagerFactory' defined in class path Resource
Good night, I have an application using Spring boot 1.5.10. I’m trying to make the connection to the oracle database, but I always have this title error. Attempts: I went back to the spring boot…
-
2
votes1
answer126
viewsFixed background, no resizing on keyboard
I have the following layout for color, set in background of LinearLayout: background.xml <?xml version="1.0" encoding="utf-8"?> <shape…
-
2
votes1
answer175
viewsHow to get the number of lines from a Stringlist and apply?
I have a StringList inside a file mensagens.txt, I’d like to count how many lines there are StringList contained within that file. For each line of the string 1 code will be executed within the…
-
2
votes3
answers5148
viewsReturn BD data using List/Arraylist - Java
I have a problem, I set up a dynamic table in Postgresql and I need to print the lines of it, performing a method in Java, whose beginning is already pre-set. That would be with a List simple with…
-
2
votes1
answer253
viewsWhen should a utility class become an injectable dependency?
I often write small utility classes to solve some minor problem in my code. For example (I will use Spring for DI): @Service class PessoaService { public PessoaResponse converter(Pessoa pessoa, Long…
-
2
votes0
answers119
viewsPrint with Java with IP-configured printer
Well I needed to solve a problem which is, since the software is going to run in the cloud, I was thinking of sending the information to the printer via the IP-configured printer on the machine,…
-
2
votes1
answer659
viewsJava Recursion - MDC
How can I implement a counter in the code below to know how many recursive calls will happen to calculate the MDC of 14 and 18? package Aula01; import javax.swing.JOptionPane; public class Exer01 {…
-
2
votes0
answers86
viewsPrecision Radius - Googlemaps
It is possible to identify when the radius of precision is small? In the examples below when I open the application it is very far from my location, with a very large radius, in the next the radius…
-
2
votes4
answers7785
viewsCalculate circle area
I’m having trouble writing this exercise in Language Java, using the IDE Eclipse: Develop a program to calculate the area of the circle. In this precise exercise assign to Pi (π) the value of…
-
2
votes1
answer47
viewsNull Pointer after Try catch
Servlet: @WebServlet("/AdicionaContato") public class AdicionaContatoServlet extends HttpServlet { @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws…
-
2
votes2
answers786
viewsDifference of months between two dates, without considering the day of the month
I am making an application for labor calculations. I need to receive two dates and know the amount of days/ months/ years. Ex.: from 08/03/2017 to 07/03/2018 is to give 12 exact months, in my code…
-
2
votes1
answer65
viewsProgram works by debugging but not running
I’m doing an old game and I’d like to know if the button pressed that I set in class MenuPrincipal is returning the correct value to the main class that controls the change between windows. Normally…
-
2
votes1
answer82
viewsAlarmmanager does not run on configured interval
In a method that records a AlarmManager to run every 30 seconds BroadcastReceiver: public void play(View view) { Log.i("lgg", "Botão: broadPlay"); Calendar calendar = Calendar.getInstance();…
-
2
votes2
answers143
viewsHow to program according to good OO design practices?
I did this program, simple and nothing complicated. My problem is that although this is doing exactly what I want, it does not follow correct patterns of object-oriented design. What should I do to,…
-
2
votes1
answer936
viewsMake java.sql.Date object to dd/MM/yyyy format
I got a field that’s like String, where a data in format dd/MM/yyyy , I’m converting to java.sql.Date, the result is: 2018-01-01. What I needed was to get the date in the format : dd/MM/yyyy, which…
-
2
votes1
answer552
viewsStore digital certificate on Server
I am creating an application that will work and manage digital certificate of customers. The idea is to import the customer’s certificate and I leave available subscription and transmission methods…
-
2
votes0
answers29
viewsAnalyze Java Application Performance
I wonder if there are applications for monitoring transactions for an application made in JSF (JBOSS Server) with SQL Server database. Application is quite slow and this may be due to…
-
2
votes2
answers1089
viewsHow to put information in the attributes of an object using Arraylist?
I created a Class Cliente with attributes name, age, address,Cpf. And in the main class I went to do a ArrayList of the kind Cliente, thus ArrayList Cliente<String> = new ArrayList<>();…
-
2
votes1
answer233
viewsInvoking a method by reflection
I took a look at that question You can pass methods as a parameter? and tried to invoke a method from one class, in another, passing as parameters the screen/class and the method name. The purpose…
-
2
votes2
answers248
viewsDatatable column row with more than one attribute
I have a Datatable with several columns. One of them is a column that should display more than one attribute in each row of that column, as it is part of a Manytomany relationship. This column will…
-
2
votes1
answer249
viewsHow to count the number of all instances of a class and their respective subclasses?
I have a class A, where A extends into B and in C. I have a counter of instances in A. public Class A { ... private int nInstancias = 0; ... public A(){ nInstancias+=1; ... } ... public int…
-
2
votes1
answer364
viewsArrange Boxes vertically
I wanted to put panels in specific positions, so I tried to combine some layout managers, but I still didn’t get the result I need. I tried to use the gridLayout, so the components wouldn’t be…
-
2
votes1
answer3188
viewsConfiguring Multiple Databases in Spring Boot
My application has a remote database connection (Sqlserver), but I would like to perform a small duplication of certain less volatile data in a local and embedded database (H2) to gain in…
-
2
votes1
answer220
viewsModify the indices of each item in a Treeview Java FX or Treeview.getSelectionModel() override method. select(int index)?
Greetings to all. This is my first post here. I am developing a Java FX project that consists of a form with a Treeview whose items are obtained from an Arraylist, previously completed through a…
-
2
votes0
answers45
viewsWhy does this algorithm skip the if?
import java.util.Scanner; public class NumPri { public static void main(String[] args) { Scanner le = new Scanner(System.in); String produto, nome, resp; double desconto, acrecimo, preco, novoPreco…
javaasked 6 years, 7 months ago Lucas Simões 21 -
2
votes1
answer10546
viewsHow to get objects from a Json array using Jsonarray in java?
I’m having a little difficulty getting information from an Array of Json, as it is giving the error: Exception in thread "main" json.org.Jsonexception: Jsonarray initial value should be a string or…
-
2
votes1
answer42
viewsI want to know how to pass an object to Activity using the following code
public class PessoasDAO extends DataBase { public PessoasDAO(Context context) { super(context); public Pessoas findByPass(String senhaLogin) { String sql = "SELECT * FROM pessoas WHERE SENHA_PESS =…
-
2
votes1
answer305
viewsjava.sql.Sqlexception: Can not Issue data Manipulation statements with executeQuery()
My key insertion is not being done. And the error that occurs in the console is: java.sql.SQLException: Can not issue data manipulation statements with executeQuery(). at…
-
2
votes1
answer39
viewsHow best to relate this entity
in my application I have a user entity that relates many to many with the entity courses (a user can enroll in many courses and a course can have multiple users) And the entity courses relates from…
-
2
votes0
answers77
viewsJava - Print on Bematech_com3 port
I need to print a non fiscal paper in Java. The customer’s machine already has a Bematech 4200 installed in the Bematech_com3 port: I’m trying to print using the following method: private void…
javaasked 6 years, 7 months ago Gabriel Augusto 21 -
2
votes1
answer1446
views -
2
votes1
answer49
viewsError using Asynctask more than once
I am developing an application for android that connects to a webservice, to make the connection part I used an Asynctask to avoid crashes, but when I run the application I can register the user…
-
2
votes0
answers555
viewsAllow access to S3 files without exposing AWS URL
I need to generate links to download files that are stored in S3, but my company does not want to expose the AWS URL. Our system is developed in Java and Spring, until then the system recovered the…
-
2
votes2
answers724
viewsParsing a timestamp with Timezone
I was making a little code to implement a treatment case in a friend’s application module and got stuck with a problem. This is a unitary test. To put in the application module I would have to make…
-
2
votes1
answer199
viewsHow to randomize the values of an object in java
I am building a card game program, in which at a certain moment he must mix the cards and pick up the one that is at position 0, but I cannot do that. Follows the code: public class Baralho {…
javaasked 6 years, 6 months ago Marcos Paulo S. Rezende 351 -
2
votes1
answer746
viewsConsulting in a list (IN) - Predicate and Specification - JPA Criteriabuilder
Hello, I have to create a dynamic query based on the following scenario in a RESTFUL application using Springboot and JPA (I am using Jpaspecificationexecutor): I have two entity classes (Entity),…
-
2
votes1
answer115
viewsIs there a way to do "Migration" in Rabbitmq?
Hello! I wonder if there is any alternative to create/change/remove Exchanges, queues and bindings without relying on the framework (in my case, Spring) for this. Often we need to change the name of…
-
2
votes3
answers253
viewsRefactor code using Factory Pattern without using the if-elseif condition
I got the following Factory. In it I urge a class responsible for parsing the file in question. For this parser to be instantiated, it is first verified in the conditions whether that parser is…