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
votes1
answer187
viewsDoes Garbage Collector remove all objects or only those that have no reference?
In a Java application there are objects that are not being used, among these objects there are those that have no reference. Like the Garbage Collector deals with it? He removes all or only those…
-
2
votes1
answer263
viewsTypescript "private" access modifier
In most examples I find Typescript I see that the class attributes do not use the access modifier private. It is a matter of design or there is some difference in operation compared to Java? export…
-
2
votes3
answers514
viewsReturn number of days for the end of the year
How could I make to return the amount of days to the end of the year, counting on today. import java.time.LocalDate; import java.time.Month; import java.time.Period; import…
-
2
votes1
answer1738
viewsFormat a coin-style textfield
I’m using Netbeans, and I can’t show the formatted value as a currency, for example R$1,200.00. When I type in the text field, zeros do not appear. I have a form with two fields: One for name and…
-
2
votes2
answers2513
viewsException in thread "main" java.util.Inputmismatchexception
I made a simple program, just to calculate a mathematical function to get an exact result, but there were some complications in Java. Digite o valor de x: 0.2 Exception in thread "main"…
-
2
votes1
answer154
viewsDoubts about class composition or inheritance
I’m having some doubts in that composition between the ClienteJuridico and Clientephysics with the NotaFiscal. I did some research and saw that the objetos of these classes within another, in case…
-
2
votes3
answers2409
viewsWhat is the best way to send my Spring Boot project to the server?
I’m building my first application Java Spring Boot. In this first experiment, I’m having trouble using Git and sending it to the server. The main idea would be: I pull into a private repository,…
-
2
votes1
answer47
viewsFragment being used by two different activties
I have a Ragment that is inflating a Recycler view, so far so good. The problem is that this Fragment needs to inflate into two different Rawer navigation, and when it comes to casting, I can only…
-
2
votes2
answers53
viewsProblem pulling server list on Android
Whoa, guys, I’m pulling a list from the server and populating a RecyclerView with that list. But when the list is empty, I want a message like: "There are no entries for that product yet". But not a…
-
2
votes1
answer700
viewsHow to add Onclick in a Fragment?
I’m trying to add onclick in my Ragment, but I’m not getting it, where it’s wrong? @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {…
-
2
votes2
answers495
viewsAdd interest per plot with Bigdecimal?
I am creating a system where I need to calculate the interest and add the installments of a loan. For this, I am using BigDecimal and I’m unable to perform the mathematical operation following the…
-
2
votes1
answer887
viewsError creating project in Maven
I am trying to create a project using Maven with the following command: mvn archetype:generate \ -DarchetypeGroupId=org.apache.maven.archetypes \ -DarchetypeArtifactId=maven-archetype-quickstart \…
-
2
votes1
answer188
viewsError deploying to glassfish server
Project not Rada on server after deploy. glassfish 4.1 Project cdi, jsf, primefaces, jpa System error: WELD-000335: Context is already active java.lang.Illegalstateexception: WELD-000335: Context is…
-
2
votes1
answer128
viewsWhat is it for and where should I use "strictfp"
I was reading the Java 9 specification and came across the keyword strictfp, What good is only that it is not clear. What good is that and where I should apply it? Why is it not so used in the…
-
2
votes0
answers106
viewsLearning Problem with Springboot
Hello, I’m starting my study at Springboot, where I got to a part that I couldn’t solve on account of an Exception, where I’ve seen on various topics of how to solve, and none worked for me. I…
-
2
votes1
answer340
viewsHow to create Java constants?
A java constant cannot be changed, but can be assigned an initial value via another variable ? For example, if we have in our program a method that hypothetically calculates the import rate of a…
-
2
votes1
answer485
viewsCreate JPA project without persistence.xml?
I created a project with Swing and JPA and is working well, now I want to remove the file persistence.xml and create a class for him to work in his place. I’m researching some way to do this and I…
-
2
votes1
answer265
views -
2
votes2
answers156
viewsHow to "fix" an exception?
We can treat an exception thrown by a line of code in order not to let the program break, but how we can fix it? Scanner sc = new Scanner(System.in); try { String[] vect = new String[1]; vect[0] =…
javaasked 5 years, 10 months ago Kevin Ricci 165 -
2
votes1
answer170
viewsCalculations with String in Java
I need to average some numbers I receive via JSON in the format of Strings, this calculation must return a value so that I can set it within a TextView on Android, but I’m not able to format this…
-
2
votes1
answer1394
viewsAdd External Library . JAR, to MAVEN project using VSCODE?
I am developing a JAVA project together with MAVEN to be compiled. However, I need to put the library jar. that is already on my computer in the MAVEN project and pull the data that is inside it to…
-
2
votes1
answer117
viewsHow to change Java’s final property to C#?
Which property in C# corresponds to final Java, I need to change my variables final String mensagem = "Tokio Marine Seguradora S.A."; to something corresponding in C#. using System; namespace…
-
2
votes1
answer191
viewsJSONP breaks at two points (" : ")
The server sends a JSON, normal. Follows the code: @GET @Path("email") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public String getEmail(){ ViewStatisticsEmail…
-
2
votes2
answers528
viewsStandard Builder design, why should I use it?
This example of design pattern can be found mainly in the book Design Patterns Elements of Reusable Object-Oriented Software, a widely known book both in the academic field and also its content is…
-
2
votes1
answer64
viewsDifference of use of immutable object in method argument or outside it
If I have the following String of which it was created: String s1 = "Primeira String"; When using the method: s1.toUpperCase(); nothing happens because an instance has been created and has not been…
-
2
votes1
answer180
viewsPersisting in Database from a file
What would be the most efficient way to read a file and write to the Postgres database? I’m posting a code where I can do, but postgres limits me on the connection number. Now follow the error: Set…
-
2
votes1
answer195
viewsRestful with Spring, Hibernate, Maven, Postgresql and Wildfly - Createcriteria
I am doing a Restful project with the following frameworks and am going through a problem, I created a User class to relate to the database, then I created the userDao to carry out the CRUD methods…
-
2
votes0
answers25
viewsFill a table by selecting a p:tab
I have two tables in different tabs and when clicking on each one, the table must be filled. I am using the same list to fill the two tables, what changes is the SQL for query that varies according…
-
2
votes0
answers207
viewsRelationship between three tables - Postgresql
need to make a relationship between three tables in the database in Java, created the two entities and the methods of the two entities, now need to insert a relationship table that has only two…
-
2
votes1
answer253
viewsHow to generate a value containing the "last Friday of the month" using Java Localdate?
I am receiving data from a CSV file with some data, and one of these data contains random dates in the following format: mm/YYYY. I have a parameter private LocalDate date. And from the generated…
-
2
votes1
answer2583
viewsAccess denied for user 'root'@'localhost '- Application connects via command but not in Wildfly 10
Settings: Wildfly server 10.1.0 Mysql 14.14 Mysql-Connector- 8.0.15 Hibernate 5.2 Permissions granted to the user: GRANT ALL PRIVILEGES ON bd_billings.* to root@localhost;FLUSH PRIVILEGES; ALTER…
-
2
votes4
answers2676
viewsProblem with Beans in spring : No Qualifying bean of type
I’m having the following problem with the Beans in spring: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'agrupamentoTaxonomiaController' defined in…
-
2
votes0
answers162
views -
2
votes0
answers287
viewsJSF + Wildfly multi-bank connection dynamically
Hello, I have a web application using JSF + CDI + JPA and Wildfly 8 as the application server. So far I’m letting the server manage transactions, where the connection information with the database,…
-
2
votes1
answer208
viewsJava - DAO+Hibernate+JPA+JDBC+Tomcat+Servlet
I am advancing the Java course and came across DAO, JPA, Servlet, Hibernate and Tomcat. I understand that DAO deals with the database, that Hibernate is a framework for this, that JPA transcribes…
-
2
votes1
answer909
viewsHow to close one screen after opening another?
I’m having trouble closing screen, I’m programming in eclipse. When running, the program opens and the Login window appears, when the user enters the correct code and password, a message appears to…
-
2
votes2
answers400
viewsSlow search ignoring accents
I have a list of objects and I’m doing a title search. I use the Normalize to make the comparison by ignoring accents: public static boolean containsIgnoreCaseAndAccents(String haystack, String…
-
2
votes1
answer144
viewsSkyrim style item system
I am developing a 2D RPG in C# Skyrim style, and I am on the part of implementing the game items, but with many difficulties. I wanted to do a mechanics similar to Skyrim in which you have a range…
-
2
votes2
answers299
viewsRegex - Selecting the first occurrence of a sequence of a number block
I have a String sort of like this: 987654 original4343 - Co 123456 asd.pdf This String may vary the groupings of numbers, but what I need is to get the grouping that has 6 digits. So I did this…
-
2
votes1
answer389
viewsWorking with Javaweb Dates
Hello, I am doing a project that manages all projects of my company, I am using Hibernate, Javaweb, primefaces, TDD and MVC standard. My entity is shaped like this for date variables:…
-
2
votes1
answer724
viewsGiven two numbers A and B, creates a third C by mixing the first two alternately?
Given two integers A and B, create a third integer C by following the following rules: The first number of C is the first number of A; The second number of C is the first number of B; The third…
javaasked 8 years, 2 months ago Elton Silva 45 -
2
votes0
answers73
viewsAccess database connection using java
I’m a beginner in java programming, and I’m trying to make a program that connects to a database and saves the information there. I created a specific class for the connection and created a method…
-
2
votes1
answer646
viewsAndroid, PHP e Httpurlconnection - Send a message to PHP with UTF-8
Gentlemen, good morning/afternoon/evening! I’m having trouble accentuating words. The back-end of my system works in PHP chatting with an Android app. When I send the App message to the PHP server…
-
2
votes2
answers1186
viewsFind the jdbc mysql driver and establish connection
I’m trying to make a connection to java directly with jdbc. I inserted the mysql jar jdbc into the project properties, javabuildpath and adding the external jar. I am making the following example…
javaasked 8 years, 2 months ago André Nascimento 1,258 -
2
votes1
answer75
views"Error: Can not Issue data Manipulation statements with executeQuery()" no Select
Doing the method to select all data from a table, but is returning me error. console: Open bank. java.sql.SQLException: No value specified for parameter 1 No value specified for parameter 1 at…
-
2
votes1
answer216
viewsJsf 2 - Datatable does not select the line at the click and does not recognize paging
I’m using the Jsf 2 WITHOUT Primefaces and would like to know how I do to solve the following problem: My DataTable is loading the data correctly, but it does not allow me to select the line that…
-
2
votes1
answer67
viewsHow to Hibernate Create a Foreign Key Elegantly
I’m studying Ibernate, how his technology works to create tables and fields. I noticed that when it comes to a Foreign key, it creates an unrepresentative name, which is calculated in some way. With…
javaasked 5 years, 8 months ago Josemar Sabino 77 -
2
votes1
answer487
viewsHow to create this class hierarchy?
In this exercise, I have to create a class within another class or are independent classes? An animal contains a name, length, number of legs (default is 4), one color, environment and a speed (in…
-
2
votes4
answers2850
viewsSelenium cannot find by id
I’m running a test with testNG along with Selenium org.openqa.selenium.By Test, do this search: driver.findElement(By.id("idRoleCheck:0")).click(); Gives the following error:…
-
2
votes1
answer1973
viewsHow to upload files using Selenium Webdriver in Java
Can someone help me to upload a file using Selenium using Java code? I made the code below: firefoxDriver.findElement(By.xpath("//a[@ng-model='picFile']"));…