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
votes3
answers209
viewsPolymorphically manipulating subsclasses
How Superclass Manipulation of Subclasses Works? In this code, the array of one class, prints the values of other classes. zoo java. public class zoo { public static void main(String[] args) { Vaca…
-
2
votes1
answer135
viewsNative query count does not return the same type in SQL Server and H2
Hello, I have a native consultation that makes a simple count of records from a table: public Long contar() { String sql "SELECT count(*) FROM Order"; Query query = query.createNativeQuery(sql); //…
-
2
votes1
answer103
viewsHow to transition to the previous Fragment when pressing the back button?
I’m having the following problem: I have an Activity, in which I call a Fragment as follows: FragmentManager fm = getSupportFragmentManager(); Fragment frag = new MyFragment(); FragmentTransaction…
-
2
votes1
answer94
viewsWhen I use the @Transactional annotation the Autowired variables become null
When I use the annotation @Transactional in a method annotated with @RequestMapping all variables annotated with @Autowired are getting null. Has anyone ever been through this? Could you give me…
-
2
votes1
answer73
viewsIs it possible to use libraries within the structure of the java project?
My question is the following, can I by relative way link my . JSP to a library within the project directory? Or only in the server directory: Webapps, etc? At the moment, when I want to show an…
-
2
votes1
answer699
viewsGrab Id of an objects in the combobox
In a Frame for registration of cars, I have a combobox1 with the brands of cars and another combobox2 with the models, when I choose a brand in CB1 only appear in CB2 the models related that brand.…
-
2
votes0
answers35
viewsCDI bean that goes up with the application
Is there any way to start a CDI bean next to the application I have the following bean: @ApplicationScoped @Named public class MyBean implements Serializable { @Inject private Helper helper;…
-
2
votes0
answers231
viewsConversion from array to two-dimensional array using parameter
I have a question regarding the conversion of vectors (array) to two-dimensional vectors. I need to read a string and separate the columns when a blank is found. I did this using the method split()…
-
2
votes1
answer204
viewsLoading Lazy in Datatable of Primefaces does not bring the record data
I got a shipment lazy in DataTable of Primefaces, and in this table I upload I want to edit a record. Clicking on the line will open a dialog with a form for editing that record. But clicking on the…
java hibernate jsf-2.2 primefaces-5.2 java-ee-7asked 6 years, 3 months ago Raimundo Almeida Matos 35 -
2
votes1
answer162
viewsPrimefaces, p:fileDownload ajax="false" nullPointerException
Hello, I’m new here, I’ve searched for Google of life and here in Stack something similar but I can’t find. I’m not as experienced as DEV so who can help... The problem is the p:DownloadFile. At…
-
2
votes0
answers31
viewsXSD with Schema with Restriction "Pattern, enumeration, max and min" Java
I’m trying to generate a wsdl where it will generate a xsd reflecting the classes of entities. The problem is, I can’t generate the Restriction in xsd as required by each property of the appropriate…
-
2
votes1
answer134
viewsRecursion Doubt with String in Java
I’m trying to solve the following exercise: A string collection S is recursively defined by: 'a' and 'b' belong to S; if X belongs to S, then Xb also belongs to S; Write a procedure that implements…
-
2
votes1
answer126
viewsJPA returning Object different from class object type
The following query returns java.lang.Classcastexception: [Ljava.lang.Object; cannot be cast to br.com.satisfacer.model.Client public List<Cliente> teste(Cliente cliente) { return…
-
2
votes1
answer193
viewsHow to reduce JSF application CPU consumption
From a while ago, my application started to have a very large CPU consumption. I installed Jprofiler, and from what I understand from him, there’s a problem with the c3p0 from Ibernate. I am using…
-
2
votes1
answer38
viewsCode before or after super
When screams a method, always comes the super of the parent class, but at the time of coding the right thing to do would be before or after it? In the example below the right would be this:…
-
2
votes1
answer228
viewsHow to resolve a synchronization with the server when there is connection drop on Android?
I’m making an application, where has a job registration in Sqlite that should be synchronized with the server in PHP with Mysql. After doing a lot of research, I couldn’t find any answers to my…
-
2
votes1
answer185
viewsHow to access a protected attribute of a package in another package?
I have the animal pack with two attributes: name and rating. package heranca; public class Animal{ protected String nome = "Leão"; protected String tipo= "Mamífero"; } ... And I have another test…
-
2
votes2
answers1277
viewsHow to manipulate a CSV file column?
Hey, guys! What’s up? I am learning Java and need help with CSV files. I can read the file, but I need to perform operations with a few columns. Example, with fictitious data, of the table I am…
-
2
votes2
answers95
viewsDoubts with the use of IF / ELSE in C
When I run this code and type sex=M or =F, all conditions are executed as expected. When I type sex=m or =f, only the first condition is met, regardless of the age value. Can anyone explain me right…
-
2
votes1
answer15
viewsHow to get Width of Imagebutton
How can I get the width of an Imagebutton defined in XML 0 being defined by weight? <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"…
-
2
votes0
answers119
viewsJoin with Specification
I have the following query: SELECT tab1.nom_shopping, tab1.nom_fantasia, tab1.luc, tab1.dat_vencimento, tab1.num_boleto, tab1.val_saldo_aberto, tab2.num_cpfcnpj negativado,…
-
2
votes1
answer230
viewsTableview bring date, mysql database
I have a Table View, which receives the data of a table in my Database, until then I was able to bring the data normally, but the date is different from the one registered in the database, always…
-
2
votes2
answers104
viewsPriority running android thread
I have the following code for printing in P.O.S on Android; Before calling pass the data to thermal printing, I make the call to test if the printer has paper or is all right with it.…
-
2
votes2
answers611
viewsJava recursive function to calculate: e = 1 + 2/1 + 3/2 + 4/3 + 5/4 + ... + n/(n-1)
My code: /** * Funcao para calcular: e = 1 + 2/1 + 3/2 + 4/3 + 5/4 + ... + n/(n-1) * * @param termos - quantidade de termos do somatorio * * Teste: * para termos = 4 * soma = 1 + 2 + 1.5 + 1.33... *…
-
2
votes1
answer154
viewsProblem with "Exception in thread "main" java.lang.Nullpointerexception" in recursion
I’m trying to implement a family tree in Java but I ended up facing this problem that I don’t know how to solve: Exception in thread "main" java.lang.NullPointerException at…
javaasked 6 years, 1 month ago Joao Marco Barros 23 -
2
votes1
answer198
viewsHow to print sentences from minor to major?
I need to make a class that receives 3 user sentences and prints in order from the smallest sentence to the largest: Make a program to read three user phrases and show on screen the three sentences…
javaasked 6 years, 1 month ago Marcelo Henrique 33 -
2
votes3
answers148
viewsTransform Jsonarray into Class Object
I am consuming an API in my application that returns me an array of names, I created a class to assign each name to 1 instance but I am having problems to take this Jsonarray and transform into…
-
2
votes1
answer155
viewsDTO with List using Jpacriteria
I have two entities Scheduler and Intervalodehoras. These two entities have other relationships that when I do a search with Rest, comes a lot of data unnecessary. To avoid this I created two DTO…
-
2
votes0
answers48
viewsJaxb converting abstract class with Retrofit
I have a Core project where there is a User class @XmlSeeAlso(value = {UserClient.class, UserProfessional.class}) public abstract class User implements Serializable { Userprofessional class @Getter…
-
2
votes3
answers1908
viewsHow to upload image using Spring Boot?
I’m learning to use the Spring Boot and I need to create a field in the form that loads the image to be used. How do I map the directory and save to a particular project folder? Example: through the…
-
2
votes0
answers110
viewsHibernate does not consider field for Insert
I have a class Cliente which has composite key: @Entity @Table(name = "Clientes") @IdClass(ClientePK.class) public class Cliente implements Serializable { //@EmbeddedId //private ClientePK…
-
2
votes0
answers169
viewsDynamically generate JSON from android form
Context: I have a Cordova app that there are SUS forms with more than 30 fields that is sent to the server through JSON. I’m building a native android APP for the same function; Problem: Need to map…
-
2
votes1
answer125
viewsAttribute or private field and getter and Setter in Java object-oriented programming
In object-oriented programming in Java, when I create any attribute or private field, without their respective methods getter and setter has to define the attribute as final or need not? For…
-
2
votes1
answer112
viewsHow to make a method wait for the java server response using Retrofit2?
Hello friends I have the following method that requests to the server: public MetaDataR metodo1(final String m) { Call<MetaDataR> call2 = new RetrofitConfig().getMetasService().getMetas(m);…
-
2
votes0
answers321
viewsHow to Make Multiple Threads in a Java Loop
Description of the Problem I’m making a Pokedex, in which one of its features is to filter all the Pokemons of a certain type. I managed to implement this functionality, but the execution time is…
-
2
votes1
answer738
viewsPermissions Spring Security
I’m having trouble with the user permissions using Spring Security. I registered the user assigns to him the permission due to him, but when accessing the system the option in the menu that the user…
-
2
votes0
answers256
viewslocalhost redirected it too often
Good afternoon, I am trying to direct a system user to an error page in case something goes wrong with the session or if the user is denied access to a particular page etc... I’m using Spring…
-
2
votes2
answers77
viewsArray is not showing the data that should be there
Class Interface: switch(opcao) { case 1: Usuario umUsuario = new Usuario(); umUsuario.criarUsuario(); break; case 2 : System.out.println("Busca de usuario"); System.out.println("Forneça o cpf do…
-
2
votes3
answers711
viewsDrive Alert using Selenium in Java
In addition to handling javascript alerts with Selenium Webdriver, it would be possible to invoke Selenium code execution-time alerts in the browser? I would like to create the 3 types of javascript…
-
2
votes3
answers658
viewsJavafx: Location is required
This is the main code, I’m having problems regarding Fxmlloader, because I’ve tried several ways and the path is never found. package com.quixada.ufc.fbd.main; import java.util.ArrayList; import…
-
2
votes2
answers3102
viewsHow to put a wait time for the code to run?
I’m playing a little game of memory, more like learning in Java. I will present the code and then explain the question. private void testar (ImageView img, int resultado1, int resultado2) {…
-
2
votes2
answers2340
viewsError: "java.text.Parseexception: Unparseable date: "2018-11-14T12:12"
I have the following data insertion interface: The comments below represent attempts to fix the error but none worked. In HTML the type is datetime-local, in the bank the type was created as…
-
2
votes0
answers730
viewsNetbeans Maven Plugin Error
I am trying to run a project in netbeans and is giving the following error "org.codehaus.mojo:exec-Maven-plugin:1.2.1:exec". I searched for the error, and found the following solution: right-click…
-
2
votes0
answers57
viewsThread in eternal Wait state, does not wake up with the notify
Good morning, I’m having a problem in a project involving Threads, I’m starting to mess with Threads right now in a college job and I’m having doubts about Thread being in the state of "WAINTING"…
-
2
votes1
answer315
viewsHow to count the number of comparisons of an algorithm (insertionSort)?
I have a college job where I should create some vectors with random numbers and then sort in some methods(Insertion,Bubble,merge,etc). After sorting, I need to count the number of comparisons that…
-
2
votes1
answer51
viewsTable Not Loading
I’m trying to make the table list load and not loading always gives this error Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem: The constructor…
-
2
votes1
answer360
views.jar cannot find the path to the ireport reports
Good afternoon Gentlemen! I have a problem and none of the other posts could help me... I was checking my TCC and I just came across the following problem: My executable. JAR cannot identify the…
-
2
votes0
answers84
viewsSystem search using Angularjs and java
I have a Java back-end: JPA, Hibernate. Entities working correctly, I even have a class Searchresource @Path("/search") @ApiDefinitionBase @Produces(MediaType.APPLICATION_JSON)…
-
2
votes2
answers2154
viewsConverting Int to String!
I am trying to recover some information recorded in the database, only when an error happens, because I am trying to take an "integer" value and pass to "String", then I am not able to do this…
-
2
votes2
answers1117
viewsCheck if a value exists in the Firebase Realtime Database
I have a database with this structure: what happens is that when creating a new user, I need to check if there is no longer a registered equal nickname, but I am not able to do this. Here’s the code…