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
-
4
votes0
answers58
viewsWhy do numbers(long, int) starting with 0 end up having other values?
I was doing some tests on a phone number formatter when I tried this entry for a long: 033222221111L, compiled normally (Yes, in the real world it would not make sense an entry like this, if it is a…
javaasked 9 years, 9 months ago Fernando Leal 9,770 -
4
votes2
answers187
viewsJava PDF Report Error
I have a little java program for PDF reporting. The problem is that every time I send the PDF via Email, it opens the PDF on the screen. Where can I change, so it doesn’t open on the screen when…
-
4
votes7
answers10560
viewsHow to test if an Edittext is empty?
I would like to know how I do to test whether a Edittext is empty or filled on Android. For example, I want to make an app that will perform a registration, but there are fields that cannot be empty…
-
4
votes1
answer1026
viewsProblems with chat sockets with NO-IP host
Well, first of all, I’ve searched a lot of sites, including here, how to do this. I tested codes and modified but still, I kept getting errors. The problem is the sockets to make the connection. I…
-
4
votes1
answer348
viewsHow to clone values of an object
How can we make an object equal to the "values" of an object? Whereas my object has other objects, and lists of other objects.
javaasked 9 years, 2 months ago David Schrammel 2,310 -
4
votes2
answers1633
viewsSplashcreen plugin (Cordova) and icons do not work on Crosswalk
I’m using this module that automatically adds a Crosswalk wrapper to a Cordova project. Obs: It requires "Platform" to be [email protected]. Okay, then I give the command to Wrap the Crosswalk in the…
-
4
votes3
answers2212
viewsHow to use replace() for the last occurrence?
The method String#replaceFirst() is used to replace the first occurrence of a substring in a string, but how should I proceed if I want to do this with the last occurrence? The doubt is as follows…
-
4
votes1
answer112
viewsThread execution - Java EE - Jboss
I have a web application using Jboss EAP, JSF, CDI, EJB and need to start a thread whenever Jboss starts. The thread belongs to the Tinyradius package that implements a Radius server. How can I…
-
4
votes2
answers386
viewsError while trying to run a class
This is my first post here on the stack, I’m having a hard time running this class in Netbeans. I’m using version 1.8.0_40 of Java, I’ve tried searching for some solution, but I can’t find. public…
-
4
votes2
answers220
viewsAlternative to create a new method in a String object?
I have the following situation: I have a txt file of defined positions (type CSV, CNAB, etc) to process and extract values. For the purposes of understanding, follow the code I made and it’s working…
-
4
votes2
answers630
viewsJava Fork/Join Does it work the same as C Fork?
Discussing with a friend about a matrix calculation solution that we are developing, the following question arose. Java Fork/Join Framework operation is equal to C? Reading a little I could not…
-
4
votes2
answers247
viewsWith resource in Java
Hi, some time ago I discovered that some programming languages have a feature called with. For example: In JS But in Java I don’t know anything like that, someone does ??…
javaasked 9 years, 1 month ago Ilario Junior 287 -
4
votes1
answer3297
viewsGenerate random numbers in Java
How to generate only numbers larger than 2? How to generate only numbers larger than 2 and the generated numbers have to be multiples of 3(eg. 3, 6, 9)? How to generate only numbers smaller than 10?…
-
4
votes3
answers1949
viewsImplement and perform joint operations on chain lists
Could someone help me implement a chained list to perform set operations? Without using native Java functions such as ArrayList. The algorithm already generates a chained list and adds new nodes,…
-
4
votes1
answer1031
viewsHow to format a String with other elements using format()
I would like to know how to format a String 08041995 on 08/04/1995 using the Java format() method PrintStream ps = new PrintStream(arq); String valor = "250,35"; ps.format("R$ "+"%s", valor);…
-
4
votes4
answers257
viewsUse of setters in the builder
I wonder if there’s any difference, semantically speaking, between these two builders: public Aluno(String n, float n1, float n2) { this.nome = n; this.setNota1(n1); this.setNota2(n2); } and public…
-
4
votes1
answer1412
viewsHow to create a new Build.Radle?
Since I imported my project from github, I’m trying this error: Migrate Project to Gradle? This project does not use the Gradle build system. We recommend that you migrate to using the Gradle build…
-
4
votes1
answer4684
viewsHow to create a stopwatch in JAVA?
I would like to determine how long one image should stay until it returns to the other. Is there a class for that? Otherwise, how to create? Note: Preferable the absence of Threads.
-
4
votes1
answer647
viewsHow to play a sound using Mediaplayer?
How can I create a button with Soundeffect using the Mediaplayer class or any other android class? I tried using the following code I found some examples, but I was not successful. public void…
-
4
votes2
answers862
viewsReading PDF with Defaultstreamedcontent. How to close it?
I have a JSF page where I Gero a PDF and need to show it on the screen. For that, I created a <p:media> It is working, but the PDF file gets stuck (never closed) and over time it ends up…
-
4
votes1
answer1304
viewsHow to persist abstract class with JPA
I know JPA and I have other tables already implemented and working. I would like to know how to persist the classes below, since one is an abstract class and the other is "extending" it. I should…
-
4
votes1
answer1039
viewsHow to pass the Edittext value of a Fragment to the Textview of another Fragment?
I have a Fragment that contains an Edittext in which the user will enter his name. In another Fragment is Textview which will receive the name typed in the previous Fragment. Fragment Edit (where…
-
4
votes1
answer580
viewsHigh memory consumption Java Swing application
I am developing a Java application but when performing some tests and noticed that when running the application, my memory consumption increases. And as the use, it always allocates more and more…
-
4
votes1
answer493
viewsHow to get processing data and memory from Windows system in Java?
How do I show in Java code Windows memory and processing usage?
-
4
votes1
answer282
viewsMain location in a project with MVC pattern
Within a project guided by the MVC standard where the main() application should be located? Thinking a little I imagined it was the model, because it contains the most "complex" parts of code, but…
-
4
votes1
answer114
viewsError in logical TV control - Java
I’m a beginner in java and I’m having a hard time making the button btnVolumeUp raise the counter. First I have this TV class where I created the methods. public class Televisor { int canal = 0; int…
-
4
votes2
answers1419
viewsIs there any way to know when a record was added to the bank?
I would like to know the time a record was added to the bank. I will use this information to show the time a contact was added to my schedule.
-
4
votes1
answer245
viewsData Truncation with Hibernate
Goodnight. I have a problem to persist an object, Hibernate throws an exception saying that the data are too long for the "street" column, type String. Follow Pojos and DAO. Address @Embeddable…
-
4
votes1
answer645
viewsTemporary text in Jlabel
I would like to exchange the text of a JLabel and leave it for just a few seconds, then go back to the previous text. I have to execute a method that takes a few seconds to get ready and would like…
-
4
votes3
answers1738
viewsIs it possible to test only specific classes?
I have two classes of tests: class A { @Test public void fazAlgo(){ // ... } } class B { @Test public void fazAlgoMesmo(){ // ... } } My tests are taking too long because all classes are being…
-
4
votes2
answers1269
viewsHow to insert inpuText data into a list using JSF?
I have the following problem: I need a form to submit questions of evidence. Therefore, the form should contain a field for the question (question statement), and several fields for the…
-
4
votes1
answer279
viewsHow to open Jinternalframe window after login?
I am new in java for desktop and am making a program with swing, and would like to know how to make a JInternalFrame open after login is done, follow the code for analysis.…
-
4
votes1
answer247
viewsClass aggregation and attribute ratio
Aggregation only occurs when a class A, which aggregates a class B, has an attribute of the type B? There can be aggregation without necessarily having an attribute of the type of the other? For…
-
4
votes1
answer161
viewsProblem using JSF Applicationscope
I’m having a problem using the ApplicationScoped in JSF to save my country list. I made this managedBean: package view.point; import javax.faces.bean.ApplicationScoped; import…
-
4
votes2
answers402
viewsWrong formatting when opening a latex generated PDF
In my program I need to open a PDF file and pick up the text that contains it. But when opening the PDF, the text comes badly formatted. For example: Please to `my fam ? read by ? measure efforts…
-
4
votes1
answer196
viewsselectOneMenu Does not list correctly
I am trying to put selectOneMenu in my code and I am in trouble. I want to list the months of the year, by clicking to select, it lists the names side by side and not one below the other as it…
-
4
votes2
answers1261
viewsCompare value at each String position in Java?
I’m having trouble comparing a value in each position of a String, follows the example below: parametro = "30,60,90"; private int countVirgulas(String parametro) { int count = 0; for (int i = 0; i…
-
4
votes1
answer223
viewsConfigure to Eclipse show parameters name on auto-complete
Sometimes the eclipse, it shows in auto-complete the names of the variables in an easier way to understand. For example, if on this line you press Ctrl+Space : BufferedImage img = new…
-
4
votes1
answer110
viewsCriteria of the grails
Someone please tell me what this ${result[0][0]} means because they put two pair of brackets? def criteria = Person.createCriteria() def result = criteria.list { projections { max('age') min('age')…
-
4
votes1
answer38
viewsJava+Database - Add Scroll to existing user via Java
Mongodb use with Java and accurate, through Java run the following command on mongoDB: db.grantRolesToUser( "joao", [ {role:"dbOwner",db:"loja"} ] ) That is, I need to add a scroll to an existing…
-
4
votes2
answers9897
viewsWhat is JPA’s mappedBy for?
Example: @OneToMany(mappedBy = "chemical", fetch = FetchType.LAZY) @LazyCollection(LazyCollectionOption.EXTRA) @JsonIgnore private List<SimulationChemicals> simulationChemicals; Why is the use…
-
4
votes1
answer670
viewsHow to make the text fit in the text box on Android?
To set a range for the font size for the text to automatically adjust in the text box Android (TextView) the extent to which it is entering or inserting. There is a configuration to do on Android…
-
4
votes2
answers682
viewsFilter String Array records by space-separated words in Java
How do I filter the records of a Array using the search terms separated by space ? Example: I have a Array String with the following records. bottle opener box with blue padlock Brass padlock 30mm…
-
4
votes1
answer52
viewsIs it necessary to repeat dependencies (JAR)?
I have an "A project" that uses a java library . JAR , which is inside the dependencies. I exported this project to . JAR to use in "project B". This project B also needs to use the same library. I…
javaasked 8 years, 10 months ago Rodrigo Santiago 1,822 -
4
votes3
answers1999
viewsIs it possible to develop mobile multiplatform using Java?
I am migrating the development of my applications to Java to build native applications for Android. I’d like to expand my apps to other platforms, like iOS and Windows Phone. You can do this with…
-
4
votes4
answers7150
viewsIn inheritance with private attributes, does not the daughter class take its attributes from the mother class?
The devmedia article says the modifier private does not give access to its attributes in its child classes. It has a table with modifiers. In inheritance with private attributes, the daughter class…
-
4
votes2
answers567
viewsTest without "fouling" (adding data) the database
I am having trouble doing integration testing. I test my database functions. My web application does not use any framework database connection and I am unable to do tests without fouling my…
-
4
votes1
answer1203
viewsSend . txt file from one pc to another using http service
I need to send a file from one PC to another over the network, only using requests http, so I don’t have to lower the level of socket, that takes work. Someone enables me to clear up with some API…
-
4
votes3
answers5185
viewsHow do I know in JAVA that the Resultset result is empty?
I’m running it through the database, and I have a problem SQL return an empty value. It is actually possible for this to happen and therefore I need to keep ready for it. Which method to identify…
javaasked 8 years, 9 months ago Renan Rodrigues 3,709 -
4
votes1
answer853
viewsCreating doc or docx file
I was wondering if there is any lib able to create a doc or docx file directly from an android app. I’ve tried using apache poi, but it doesn’t work. I’m using android studio. I’ve tried several…