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
answer77
viewsConfirmation code
I wanted to make a scheme to confirm a question. If the answer was Yes to the question, an ok message would appear. If it was No or different from Yes, I would ask if the person would like to…
-
3
votes1
answer109
viewsUpdate Jeditorpane as a function’s data return - JAVA
Basically, the situation is this, I have a Java application that communicates with an API to update a database. The problem I face is this, I’m doing the process as follows: Application Class…
-
3
votes2
answers598
viewsError in @Onetomany mapping with JPA and Hibernate
At the moment, I’m having a problem with mapping @OneToMany/@ManyToOne in my application. I would like it when I persist my entity Sale automatically save the sale items in single shot. @Entity…
-
3
votes2
answers228
viewsHow to make a program of tables with command structures restriction?
This program is for axiliar a person to see the tables, the intention is to offer 2 options: Case 1: Table 1 to 10 is returned; Case 2: No the multiplication table of a specific number. However the…
javaasked 4 years, 8 months ago Patrik Rufino 51 -
3
votes2
answers515
viewsJava 8 stream - performance improvement
I am implemented a method that receives an integer value k (representing the amount of "vacancies") and two lists (p and q) of Integer and perform some operations. Using stream, check which elements…
-
3
votes1
answer54
viewsImplement only direct methods from an interface
Let’s say I have the interface Vehicle: public interface Vehicle { void moveForward(); void moveBackward(); void moveLeft(); void moveRight(); } And the interface LandVehicle: public interface…
-
3
votes1
answer53
viewsUse of only one attribute of an entity
I’m building a Rest API for Cities and Customers registration. My problem would be in relation to the Customer class that has as attributes personal data of the customer and a City, that would be…
-
3
votes1
answer48
viewsWhy can’t I print the values of a chained list?
I need to generate an empty chained list and do three operations with it: Add an element to the end of the list Remove an item from the list Insert n elements at the end of the list Finally, the…
javaasked 4 years, 7 months ago Guilherme Cherobim 33 -
3
votes1
answer517
viewsCalculation of age in Java
I have a code that should calculate the age, but in my test I can’t catch the day nor the month of Data and yet age comes wrong due to this. On the test returns 32 years, while it should be 31.…
-
3
votes2
answers83
viewsObjects eligible for the AG
I have the following certification issue on the Garbage Collector: 1: public class Rabbit { 2: public static void main(String[] args) { 3: Rabbit one = new Rabbit(); 4: Rabbit two = new Rabbit(); 5:…
java objects instantiate-object garbage-collector jvmasked 3 years, 11 months ago Deivson Bezerra 149 -
3
votes2
answers200
viewsEliminate consecutive duplicate string letters
How do I scroll through an array of strings and delete consecutive repeat letters? Incoming: String[] x = {"lleonardo", "joaoo"} Exit: String[] x = {"leonardo", "joao"} I created the function below,…
-
3
votes1
answer110
viewsIs it correct to use @Mappedsuperclass instead of @Entity to not create a table in the database using JPA?
Explaining the problem, I need to consult a function in POSTGRES: SELECT * from pgr_dijkstra('SELECT gid AS id, source, target, length AS cost FROM ways', 11111, 22222); "pgr_dijkstra" is a POSTGIS…
-
3
votes1
answer72
viewsHow to force the user to pass a type to a generic class?
I have a generic class called Quantity<UnitType>, and in some methods of another class, I need to get an object of that class in a specific type. See the code below: interface UnitType {} enum…
-
2
votes1
answer898
viewsUpload Angularjs image with Java server
I’m having a problem uploading a web image, I’m using the angular file upload, when I upload it saves the image in the folder Frame -> Images of the browser, and when I will read the inputStream…
-
2
votes3
answers400
viewsRefactoring with eclipse
By itself the eclipse already has the necessary for refactoring or you would indicate some tool to attach to the eclipse editor and use it more accurately?
-
2
votes3
answers1547
viewsSave same object multiple times
Solution: setar id = null Code saved 10 times if running on the Tomcat server, but running on Glassfish only adds once. <?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0"…
-
2
votes2
answers1179
viewsHow to move an icon on the map behind my location?
I’m doing a project that uses the API v2 from Google Maps. On this map appears my location that will be updated as I move. I put an icon with the police image, and I wanted that icon to come after…
-
2
votes3
answers2371
viewsCreate a button in a Listview
I am making an application and at the end of the data inserts the user will view a summary with a listView. So far so good, but I want to create, right down after the listview, a finish button, but…
-
2
votes2
answers129
viewsAlternative Flow in Spring
Faced with the situation: I am on the registration screen of cars, where I can select the brand and type the model. In case I need to register a model that does not have the brand previously…
-
2
votes2
answers995
viewsProgress bar not updated correctly
Working with progress bar (JProgressBar) I faced a problem in PropertyChangeListener. In fact, not necessarily in PropertyChangeListener, but yes at the time of returning the property being updated.…
-
2
votes3
answers12003
viewsToggle Jpanels within a single Jframe
In a Java code, I have a Jframe and within this Jframe I have a contentPane (Jpanel). I have several screens in Jpanel format, I want to exchange these Jpanels by clicking a button that is attached…
-
2
votes1
answer327
viewsMove multiple messages to a folder using Javamail
I’m looking to refactor an email manipulation code, I know you can remove multiple messages in one operation, but and to move multiple messages to a certain folder, have as? I use the IMAP protocol.…
-
2
votes1
answer216
viewsClear Target on JSF+JPA+Richfaces projects
How can I clear the Targets generated from the project when we deploy for Jboss?
-
2
votes2
answers1021
viewsProcessing of Session Objects
I’m working with legacy systems in JSF 1.2 and noticed that developers make absurd use of Session to store all kinds of objects, ranging from user-informed filters to collections. As you can…
-
2
votes1
answer1114
viewsHow not to serialize some attributes in Restful calls with Jersey and Jackson
I’m using the Jersey library in conjunction with the Jackson library to use REST-like web services. In calls, I usually use the following code that transforms a particular entity into a JSON to be…
-
2
votes3
answers1447
viewsFork in Join in Java
During a project I was suggested the use of Fork in Join of the Java API instead of threads, I found nothing easy to understand by the examples found on Google. I understood that it is possible to…
-
2
votes1
answer317
views -
2
votes1
answer527
viewsConfigure the Jackson library for dynamic attributes
I am using the Jackson library to transform the following JSON into a Java object.…
-
2
votes1
answer79
viewsIs there a way to avoid the size specifications in the Android layout?
I work with Android on a day-to-day basis, and I would like to avoid the size specs views. For example: If I make a TextView, i have to assign Height and Width properties, so: <TextView…
-
2
votes5
answers1154
viewsMap does not load, showing error
I’m starting to develop on Android, only I came across a problem to generate a simple map, I’ve seen and reviewed the documentation of Google Developer and other internet tutorials that show how…
-
2
votes4
answers2018
viewsHow to use a class-specific thread with multiple threads?
I’m with a class called Ball where I have a thread that makes some balls move in phase 1 of a game. It is possible for me to implement in this same class another thread make the balls move…
-
2
votes2
answers2748
viewsReading text file stored in raw folder through a user class
I have a test code that works fine. The function of the test is to read a text file that is in a res raw folder. It reads the text file smoothly and stamps its content line by line through Toast.…
-
2
votes1
answer368
viewsProgrammatically close jar
Currently I have a program JAVA(main), which from it calls another program JAVA (son)... this is OK.. but when I close the main program, I also want to close the son program. I’ve tried to:…
-
2
votes1
answer5101
viewsLogin with Java Mysql levels
I’m making a login system, only I’m doubtful how I can leave it with levels/ types (admin, user, client). IMPORTANT : I’m making a method that uses Taglib - "C:if", to make a Switch Case. The idea…
-
2
votes1
answer3372
viewsHow to read a JSON file that is inside a package?
I need to file a case file *.JSON. I understand that there is a library for this in case I use the json-simple-1.1.1. How it is necessary to read the file first and then work with it. My question is…
-
2
votes1
answer2235
viewsHow to create a widget?
I have in mind the @xml/widget_info the receiver in the Manifesto the layout of the widget and the Provider class is what I doubt. What it needs to have?
-
2
votes3
answers787
viewsproblems to print a double number
I’m having trouble printing a double number, for example I create a double type variable, and this gets a 1/3 split, it would have to show 0.3, what I have to do to print 0.3??? public class…
-
2
votes1
answer276
viewsAdd Elements Programmatically
I have a certain part of an application in which there is a random questionnaire. Generated by the user himself. The point is, I don’t have access to the amount of questions or what the questions…
-
2
votes2
answers1138
viewsNetbeans - How to Generate a Jar with Dependencies without Maven
I have a project in Netbeans, but I only know Maven and have some project dependencies. If you build or even run Netbeans everything works smoothly, but I wanted to get the jar and test on other…
-
2
votes1
answer1821
viewsTake all classes of a given Package that is in the classpath
I’m needing to take all the classes of a certain package, I’ve seen some codes that do this, but it only takes the classes that are part of the project itself, basically doesn’t use Reflection and…
-
2
votes2
answers891
viewsObfuscating Java code with Proguard
Problem: I’m getting warnings of Proguard and with it I can’t outshine my .jar, this is the first time I’ve received these warnings and with that I can’t finish the obfuscation. Image with details…
-
2
votes2
answers1722
viewsColumn size on a Gridview on Android
I have in my android project a gridview that I define as follows: <GridView android:id="@+id/grid1" android:layout_width="600dp" android:layout_height="fill_parent" android:padding="5dp"…
-
2
votes2
answers1399
viewsConfigure Hibernate transactions only with Jersey API Annotations
I want to use something similar to org.springframework.transaction.annotation.Transactional Spring that configures a Transaction only using only the Jersey API. Something similar to the code that…
-
2
votes0
answers146
viewsSignatures return null 'INAPP_PURCHASE_DATA' using 'In-app Billing V3'
I am implementing the purchase of Subscriptions in an Android application. So far, payment orders are already configured in the 'Google Play Developer Console' and I can debit the amount set in each…
-
2
votes2
answers16347
viewsHow to call a method when its parameter is an array?
I’m new to java and I’m having some difficulties in calling a method, well, I have the following: class main { public static void main(String[] args) { vetorFloat(vetor[x]); } private float…
-
2
votes2
answers1830
viewsPerformance in Java repeat loops
What is the difference in performance between the three types of ties highlighted below. List<Foo> list = new ArrayList<Foo>(); for (int i = 0; i < list.size(); i++) { //CODE } for…
-
2
votes1
answer1090
viewsHow to run a Bean method by clicking the rich:Editor’s Save button using Richfaces4?
Hello, I am using Richfaces4 and in my project includes the tag This one features a Save button (Disket) and my intention is to call a method in my Bean and run my code to save. I don’t want to add…
-
2
votes1
answer429
viewsProblem configuring spring data jpa project with Hsqldb
I am trying to set up a project example using Spring Data JPA with Hsqldb I made the class I would be model, to interface repository and a main class to run. I didn’t create the bank because I have…
-
2
votes1
answer89
viewsCharacter problems coming in Ndefmessage NFC
I am making a program that exchanges messages for NFC, and I am having a problem that when I want to pass a Parameter in the message appears all right now when I want to pass 2 parameters, so there…
-
2
votes1
answer577
views