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
votes2
answers715
viewsAdd the 5 highest values to an array
I have the following method: public static void topFiveSales(int idEmpresa) { List < Entidade > allList = Entidade.findByEmpresa(idEmpresa); float totalVendasByEntidade; Float[] totais = new…
-
4
votes2
answers661
viewsReturn jtable line information after selection
I have an application with 2 Jframes.. 1st Jframe: A screen with a search button and Jtextfield 2nd Jframe: A Jtable with BD information. When I click the search button in the 1st Frame opens the…
-
4
votes1
answer1949
viewsHow to split a string`and then convert to int?
I have a string "1 2 3 4 5" to divide it and save the numbers in separate variables I was reading and saw that have to use a method called Split... I tried to do it, but I couldn’t. How do I do…
javaasked 9 years, 3 months ago pedrocarboni 117 -
4
votes2
answers825
viewsAlgorithm to return the point of intersection
I need to return the relative positions between two straight lines, at this point in the program I’m sure they are competitors. My method performs the following equation to avoid the use of linear…
-
4
votes2
answers882
viewsWhat is the importance of using java interfaces or c#?
I know how to implement and use interfaces, but I can’t understand what the real reason for them is in c# or java, since once you extend your class to an interface you need to implement all the…
-
4
votes1
answer610
viewsREGEX password validation
I have a Validation problem and I cannot apply within a simple structure, 3 validations cannot have decreasing, increasing or repeated alphanumerics in the same password. For example: 00000000 ,…
-
4
votes0
answers53
viewsWhat is the advantage of using OSGI?
What is the advantage of using the OSGI to separate the modules from the project? What would transactions look like in transactions between modules, and relationships between different module…
-
4
votes1
answer930
viewsHow to authenticate on site via Httpurlconnection to access the JSON method?
I have an Android application that must request a JSON from a web application, however to have access to the method it is necessary to login to the site. How do I perform this identification via…
-
4
votes2
answers6465
viewsHow to return a list as JSON using Spring MVC (@Restcontroller)?
I want to return a list in JSON format using Spring, but I am not succeeding. At pom.xml I added this dependency: <dependency> <groupId>org.codehaus.jackson</groupId>…
-
4
votes2
answers123
viewsSome errors on Android
I’m trying to start programming on Android. I created the project and came this code: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);…
-
4
votes2
answers443
viewsWhat happens when we assign a float value to a double variable?
class Test { public static void main (String[] args){ double pi = 3.1415f; System.out.println(pi); } } When compiling and executing the above code, I got the return: 3.1414999961853027 This is not a…
javaasked 8 years, 2 months ago Igor Santos 63 -
4
votes2
answers812
viewsPegar sql Hibernate
Good morning. I have the following problem, I need to take sql executed by Hibernate and save in a string. But I have no idea how to do that, someone could help?
-
4
votes1
answer1474
viewsHow to persist a record in the database through Java restful webservice?
I already have a method that takes a json and persists in the Mysql database. I can test it by the interface created by Netbeans, which has a field for inserting a json, but how do I make an http…
java web-service java-ee netbeans restfulasked 9 years, 2 months ago Marco Aurélio Soares de Souza 125 -
4
votes2
answers709
viewsJsonarray in Jsonobject: Json.typeMistach error
In a web search I discovered that the Json.typeMistach error was due to I’m getting one JSONArray and trying to arrow it into a JSONObject. Turns out I can’t fix it, the mistake persists. Could…
-
4
votes1
answer121
viewsJava Https - Httpsurlconnection - Unsupported Sslv2hello
When making an https request I have the following Exception: javax.net.ssl.Sslexception: Unsupported record version Sslv2hello public static void main(String[] args) throws Exception { URL url = new…
javaasked 9 years, 2 months ago Micael Costa 93 -
4
votes1
answer135
viewsCheck click position on a Listview
I have a screen that has a ListView inside it, I need to identify which line was clicked to direct to the correct location. How can I do this?
-
4
votes1
answer1033
viewsslow remote Mysql database with java swing application
I have a swing java application that is connected to a remote Mysql database, that is, on an online server. When running the program it works normal, except for the slow response of the bank. For…
-
4
votes2
answers3435
viewsCompile multiple java files in the same folder
I made a very simple Java program, using the notepad and compiling by CMD. The problem is that even though the files are in the same folder, the class that has the method main() does not compile.…
-
4
votes1
answer456
viewsSave tts as audio file
How can I generate an audio file from a TexttoSpeech to share with other services (sms, Whats, messenger, ...)? I created this function to share private void shareAudio() { Intent intent = new…
-
4
votes0
answers45
viewsFramework for working with websockets in java
I need to present some frameworks in java that use JSR356 but I can’t find current information of which is most used and why.
-
4
votes3
answers1050
viewsIncreasing the size of a Textview, according to the amount of data entered in it
I am developing an app, for technical course work, and I have the following situation: I’m displaying data inside a Textview. Only there comes a time when the size is not enough. Observe the images.…
-
4
votes1
answer1940
viewsMaven: Generate JAR with Dependencies / Directory recources
I’m very lay with Maven and the fact that there is a lot of material on the Internet I ended up getting lost as I perform the operation below: I need to generate the JAR Runnable of my project with…
-
4
votes1
answer386
viewsHow to Encrypt Images with Java RC5 Algorithm
I am trying to use the RC5 algorithm with the Cipher class of Java, but it is returning an error, someone can help me? import java.io.*; import java.security.*; import javax.crypto.*; public class…
-
4
votes3
answers1870
viewsAssign value to variable in method declaration
It is possible to assign the default value of a variable within the method declaration, the same occurs in the PHP? If yes, how? Ex: I want the test function, when called, if no parameter is passed,…
javaasked 8 years, 1 month ago Julyano Felipe 581 -
4
votes4
answers392
viewsRead Internal File Name
I need to read the name of the files contained within a package, for example, read the name file01.txt, as in the image below : So I can go through the package arquivos without having to name a file…
-
4
votes1
answer230
viewsShow emoticons with independent keyboard button
I am developing an application in which I created a button that I would like you to do the same function of showing the emoticons keyboard. This image: btnMostrarEmoticons.setOnClickListener(new…
-
4
votes4
answers2266
viewsHow to generate random numbers for Draw?
I need to generate numbers for a promotion, these numbers should go from 0 to 99999. How can I distribute these numbers randomly and fairly, without repeating numbers already distributed?…
-
4
votes1
answer1310
viewsHow to align the column title of a Jtable?
I have a table (Abstract table model) and would like to center column titles. I tried the following: DefaultTableCellRenderer centralizado = new DefaultTableCellRenderer();…
-
4
votes1
answer1581
viewsJava text "encryptor" program problem
So, guys, I’m having a little problem with one of the work exercises that I have to do. The teacher provided a .doc with the instructions for a "Cryptographer" that you should apply a mask to the…
-
4
votes1
answer294
viewsProblems when drawing an oval on a panel (JAVA)
Greetings dear fellow programmers. I’m encountering a somewhat irritating error: I consider drawing a graph on the screen using circular/oval shapes. After a good number of researches, I was…
javaasked 9 years, 1 month ago Momentanius 105 -
4
votes1
answer140
viewsConvert Stack Trace to String in JAVA
What would be the best way to convert Stack Trace from a Exception in String?
-
4
votes0
answers10278
viewsHow do I leave the Android Studio interface in English?
It seems a little layy on my part (really is), but I’m not able to leave the interface of android studio in English.
-
4
votes2
answers1662
viewsApply filters to a Jtable
I have a table and in a JPANEL on top of it I created textFields and combobox with the intention of using them as filter. The method: tableRowSorter.setRowFilter(RowFilter.regexFilter("(?i)" +…
-
4
votes1
answer533
views"java.lang.String cannot be cast to ..." using access control in Servlet
I have a system made for my company and together I have the new website. I can log into the system normally with the accounts registered in the database, but when I enter a filter into Servlet, I…
-
4
votes1
answer114
viewsHow to prevent a certain key from being sent to the program several times
I’m making a calculator for year-end activity, which even works normally, as long as it doesn’t exceed typing. For example, if you sum two fractional numbers, it performs the entire sum correctly,…
-
4
votes1
answer1947
viewsHow to extract Array from JSON into an object’s List type attribute
I am using the Flickr API to get the information from the images, which returns the following JSON:…
-
4
votes1
answer419
viewsChange data from a specific position in Listview
I would like to know how I can change data from a certain Listview position. Here I upload from the database to Listview: public void carregarEmails(Cliente cliente) { ArrayList<Email>…
-
4
votes1
answer64
views -
4
votes1
answer119
viewsWhat are Crosscuting Contracts? What is the relationship with Design by Contract?
What are crosscuting Contracts? What is the relationship with Design by Contract?
-
4
votes1
answer622
viewsMaven with Proguard
Well someone could explain to me how I can use Proguard in the Maven build to obfuscate the web project (War) in the direct deploy for Jetty? <project…
-
4
votes3
answers785
viewsCreate Textview’s dynamically
I have a TextView and would like that instead of filling with a Arraylist, with all items in your setText, that it be created several times on the screen, with the respective items of this array, in…
-
4
votes2
answers848
viewsDesktop application audit log
Thinking about a Java application desktop that is running in a company, we may come across situations that the user may cause failures in your application, in this case could create a log error and…
-
4
votes1
answer82
viewsWhat library do I use to send notifications?
Hello, I’m developing an app where patients have left it in the background or even open, and when the patient’s turn arrives, the office sends a notification saying it’s his turn. Do you have a…
-
4
votes1
answer119
viewsHow to change a menu item after it has already been created?
The following I create a menu through the onCreateOptionsMenu method,. @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.filter_menu, menu); mMenu=menu…
-
4
votes1
answer1129
viewsHow to add values in Jtextfield via the button without deleting the previous value?
My problem is that I put a button so that when it was clicked, add the value 1 in JTextField. However, when I click again, it replaces the value, and what I wanted is for it to add another 1 like, I…
-
4
votes3
answers219
viewsHow to create a top numeric bar on your Android keyboard
Does anyone know how to create in Edittext XML that number bar on the keyboard?…
-
4
votes1
answer1436
viewsWhat is the formula used to calculate FPS in a game?
I’m creating a game in java using lwjgl3, I’ve seen many algorithms but all are different from each other. So simplifying my code would be like this: start(); while(running){ update(); render(); }…
-
4
votes3
answers2362
viewsHow to Recover User Session
I just wanted to retrieve a user’s session. I have a class called User system, that identifies which user is logging in. In this class, I take the session and play for an object. @ManagedBean(name =…
-
4
votes3
answers821
viewsProblem between C# system and Warsaw plugin (GAS Technology)
My project was built with the C#language. Everything was going smoothly, until some customers started reporting errors when opening my system. The error goes as follows: the client clicks on the…
-
4
votes1
answer57
viewsHow to initialize objects already declaring values?
For example in this code: public class Main { public static void main(String[] args) { Point p = new Point(); } } class Point { int x; int y; } There is a way to declare values to x and y while…