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
-
3
votes1
answer478
viewsConverting Java code to C#
I would like a help to convert the following code in Java to C#. public static long convertStringToBitboard(String Binary) { if (Binary.charAt(0)=='0') { return Long.parseLong(Binary, 2); } else {…
-
3
votes1
answer275
viewsSeparate line contents in the Bufferedreader loop
I have files txt with approximately 5,000 items, and these do not have a pattern, for example: 10 20 30 40 50 60 70 80 90 100 I need to import this into the SQLite, where each value is 1 record.…
-
3
votes1
answer750
viewsJPA make a Join of a table that has attribute @manyToOne and @Manytomany
I have a question regarding table junctions ,I have a class sale the same has Customer,dTCompra,listProducts.I would like to make a report with the product name,customer name ,product value and…
-
3
votes4
answers5979
viewsError while running spring security
I’m having the following mistake: Field authenticationManager in com.ronaldo.money.api.config.AuthorizationServerConfig required a bean of type…
-
3
votes1
answer156
viewsmap.foreach Unexpected Return value
I have the following map: private static Map<ParseCreator, Parseable> map = new HashMap<>(); I walk this map as follows: for (Map.Entry<ParseCreator, Parseable> entry :…
-
3
votes0
answers103
viewsScheduled cron message sends three times
Hi! I have a routine on a JSF+Spring 3.0.5 system that sends an email containing 4 attachments in pdfs on every 11th day at 07:01 AM to 11 addresses. My problem is that when the application is in…
-
3
votes1
answer94
viewsJSON Return to JAVA Class Conversion Error
I have a java class public class PRODUTO extends SugarRecord implements Parcelable { private float id_pro; public PRODUTO(float id_pro){ this.id_pro = id_pro; } public float getId_pro() { return…
-
3
votes1
answer135
viewsQuery using Hibernate does not bring record
I’m trying to query the HSQLDB database using Hibernate but I’m not succeeding. When I do: session.get(Usuario.class, new Integer(1)); The query is made because it shows the query mounted by…
-
3
votes0
answers177
viewsWhat is the best way to map entity with JPA composite key?
I have two tables to map in two entities. I need to list on the screen like this: Id | Produto | Cliente | Razão Social | País | Estado…
-
3
votes1
answer770
viewsStrategy Pattern with Spring Boot
I’ve been looking for solutions for Strategy Pattern with spring boot, but nothing I’ve found so far seems performatic or even functional. I have an interface like: public interface UserService {…
-
3
votes1
answer97
viewsObject getting null in the middle of the process
I am developing a system using Java, Maven, Hibernate, Primefaces and Mysql database. Within this system, I have created a program to record the amount of rainfall that occurs on the day. My table…
-
3
votes0
answers120
viewsDoubt with Loadbalance and Circuitbreaker in Microservices
I have a service structure as follows: server (Eureka), immovable (Eureka-client) and client (Eureka-client). The customer service makes a request for immovable service, using feign. I own the…
-
3
votes2
answers169
viewsOnly one class can instantiate another class, how do we do that?
Hi, I’m doing an UML on an exercise, but I can’t do a part of it. The exercise says that only the administrator class can create another contributor, I wanted to know how I could implement this.…
-
3
votes1
answer182
viewsJavafx: pros and cons of MVC, MVP, MVVM, etc
Which Model-View (MV) standard to use with Javafx thinking of scalability and good maintainability? On Google you find people recommending MVC, MVP, MVVM... maybe there are others. Some say that…
-
3
votes1
answer55
viewsCreate a method that receives a generic class?
I’ve been racking my brain with the Reflection API. I am writing a class (reader) that reads a CSV file and creates an Arraylist of objects based on CSV. I made a test class to write the code, only…
-
3
votes1
answer2248
viewsNon-static error method cannot be Reference
I’m having a problem: non Static method write cannot be referenced from a Static context. I tried to change the function to static, however, there gives it problem of: non Static variable This is…
javaasked 6 years, 5 months ago user103375 -
3
votes1
answer28
viewsI18n Springboot from an external library
Gentlemen, in my system I have an external component that contains the messagesource bean configured as follows : @Bean public ReloadableResourceBundleMessageSource messageSource() { final…
-
3
votes1
answer374
viewsHow to auto-detect the current system language?
package linguagem; import java.util.*; public class Linguagem { public static void main(String[] args) { Locale locale = new Locale("PORTUGUESE", "PT"); System.out.println("Linguagem: " +…
javaasked 6 years, 5 months ago user116018 -
3
votes1
answer800
viewsHow to convert JSON to Object and find an id - JAVA
I need to convert a JSON into an object and navigate to an ID and capture only it. JSON Example:…
-
3
votes1
answer140
viewsI can’t access a form page
I am doing a course of Alura of Spring framework, but I can not access a form page through the link http://localhost:8080/casadocodigo/products/form. Gives the following error: HTTP Status 404 - Not…
-
3
votes1
answer1050
viewsSpring Security blocks POST requests despite settings
I am developing a REST API based on Spring Boot (spring-boot-starter-web) where I use Spring Security (spring-security-core and spring-security-config) to configure the protection of different…
-
3
votes1
answer104
viewsHow to print 0.10 instead of 0.1 in Java?
The code below counts how many letters there are in a word and multiplies by 0.01. The problem is that I want when a 10 letter word, for example, is typed, to have an output of 0.10 and not 0.1.…
-
3
votes1
answer40
viewsJava: Convert point-delimited strings to nested JSON
I have a lot of attributes coming as point-delimited strings like "company.id", "company.address.number", "user.name", "isAtive", and I need to create a nested JSON with its respective values. These…
-
3
votes1
answer124
viewsError: Could not parse Configuration: Hibernate.cfg.xml
I am developing a Java Web application using Hibernate to persist the data in Mysql. When testing the Hibernate connection by the main class, the following error appears on the console: jul 18, 2018…
javaasked 6 years, 4 months ago Geovane Santos 39 -
3
votes1
answer2462
viewsSearch with accents and without accents Postgresql
Hello, I am trying to search through a field in the application, it searches the word in the database (postgres), however, has a lot of product registered in the bank, with and without accent, for…
-
3
votes2
answers309
viewsError while updating Java
A standard notification came up saying that there was a new Java update available, so I decided to update. After the update I can’t run my apps on Eclipse and the following message appears: Imports:…
-
3
votes1
answer75
viewsSonarlint x Java GC, cancel or not object at the end of the execution?
I am passing Sonarlint in a somewhat old application and fixing several "problems", but I came across a code snippet similar to: public void fazerAlgo(final String param) { MeuObjeto m = new…
-
3
votes1
answer105
viewsProblems in displaying the report with Jasperreport
In my work, I am developing a Java EE application, with web service REST (Jersey), Hibernate and Jquery on the front end. All my system requests use ajax and I am having difficulty generating the…
-
3
votes1
answer110
viewsHow can Maven’s archetype webapp work without web.xml?
I tried creating an app Maven archetype webapp in Eclipse JEE Photon: File > New > Maven Project > Next > maven-archetype-webapp 1.0 It generates the following file structure: . |-- src…
-
3
votes1
answer209
viewsDraw letters in a matrix, quantida typed by the user
I am having difficulty here to be able to type how many letters of each one it wants to be drawn. Example as in the code below shows the letters char[] letras = new char[]{'S', 'C', 'M', 'A','L'};.…
-
3
votes2
answers1131
viewsonDataChange(), in addListenerForSingleValueEvent(), is only executed after my method returns
I’m trying to check if a given email exists, with android using firebase I’m doing this way : public boolean existeEmail(String email) { final boolean[] retorno = new boolean[1]; final…
-
3
votes1
answer154
viewsError for Importing JDBC from sqlServer with Maven
In my java web application ,I needed to add a connection to a sql server database, so I put it as a dependency on Maven as described below: <dependency>…
-
3
votes0
answers54
viewsProblems running Java Application on Docker
I have the following problem. I created a container with 1GB of memory and 16GB of Swap, I am using Oracle JDK 8 Update 171 (64 bit) with S.Debian 9. Set the Java_opts parameters for the JVM to read…
-
3
votes1
answer61
viewsSpring Model 4.3.1
I don’t know how to work 100% with #POST and #GET yet, my problem must be in understanding how requests occur and when my objects are instantiated. Follow methods: CaixaOperacaoController.java…
-
3
votes2
answers115
viewsSearch information in the database with validation of Hibernate parameters
Analyze the following situation: will come in request the information of the country that can be {0, 1, 2}. The replacement method will look like this: Nomenclature of the country parameter: 0:…
-
3
votes1
answer219
viewsSpring - Thread Dependency Injection
I need a little help. I’m doing some tests with Spring Boot and I have my services + some processes I want to run in thread. Each thread will run its own service. When I inject service dependency…
-
3
votes1
answer224
viewsProblem to write foreign key to table
I am developing a web java project - using Spring , Thymeleaf , Html, Mysql . In this project I have two classes that are related by foreign key. (Technical and Position). In my view…
-
3
votes1
answer1474
viewsJava Spring Boot - Read a file from the Resources folder inside a . jar
I am writing a class that will read an ETL Pentaho Kettle (transformation). I have put the file that the class will read in the Resources / KTR folder. But when I try to run the code as a java…
-
3
votes1
answer63
viewsUndesirable result - Query SQL
Hello. I’m a problem and I don’t see a way to solve. My table data movement: My query: select avg(m.valor) from Movimentacao m where m.tipo='SAIDA' group by m.data; Man outworking: I cannot group…
-
3
votes2
answers49
viewsMy arraylist is returning the same value on all "nodes"
This code should take all the elements of a login.txt file and put inside a user array. public ArrayList<User> takeAll(){ ArrayList<User> list = new ArrayList(); User u = new User();…
-
3
votes2
answers920
viewsRecursiveness: Compute the sum of the first positive odd values starting at 5
I’m doing some exercises on and I stopped on this a few days ago. I got to the following code: /** * Funcao: Soma dos primeiros valores ímpares positivos começando em 5. * @param quantidade -…
-
3
votes1
answer2872
viewsHow do I verify that a given field/value exists in the JSON document?
{ "timestamp":"2018-10-08T16:58:38.949Z", "dataFrame":"QQ==", "fcnt":15, "freq":902500000, "port":12, "rssi":-69, "snr":10, "sf_used":10, "session_id":"f41e10e8-1c73-499c-8ad7-4cbcd54c8ebd",…
-
3
votes1
answer53
viewsSpring Rest - Use of Various Services and Repositories
I have a question about how best to implement some services with the Spring Rest, but I couldn’t find the material for this case: Let’s say I have a launch service (Lancamentoservice). This service…
-
3
votes2
answers565
viewsIs it possible to call Onclick from Textview a new Activity?
Hello, I’m trying to call a new Activity through OnClick in a TextView, but when running the application generates a crash. Here’s the Activity of from the one I’m trying to get through: public…
-
3
votes1
answer233
viewsRecover value from PATH environment variable on Linux using Java
I did not find a good topic on this subject and decided to create this question for those who are going through this problem. By using System.getenv("PATH") not listed all values of this environment…
-
3
votes2
answers102
viewsProblems using camera, generate, edit and save image
I’m trying to create an app, and part of it is to use the camera phone to take a photo, which will automatically be decreased and saved in separate folders per year / mes/ imgHora.jpg. For older…
-
3
votes3
answers800
viewsSpring Data JPA does not recognize the SQL 'Limit' command?
I am creating a REST API, using Spring Boot, which, using data from a table, displays random phrases. Giving a Google, I found that it is possible to generate random results through pure SQL: SELECT…
-
3
votes3
answers115
viewstotalcross application with images, when deploying for windows CE does not work
When I deploy my application to Windows CE that contains images on the screen or in Buttons no element is displayed, but in the emulator works normally. When I remove images it works normally.…
-
3
votes1
answer145
viewsEntities marked as FETCH LAZY are returning "null" even after a call to the GET method
Hello, good morning friends, Why my entities marked as fetch Lazy are returning "null" even when they are invoked through a get? What I learned in several courses is that when making the first call…
-
3
votes1
answer46
viewsForeign key is not printed in table
I have an entity that has the Onetoone relationship with another, but the foreign key of the other entity is not being printed in the table, the field is empty Entity having the Onetoone…