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
-
5
votes1
answer9990
viewsJava Tutorial for Reading A3 Digital Certificate
I am looking for a tutorial for implementing read cards with A3 digital certificate. I’ve never worked with anything like this before and now this need has arisen. I searched some things on the web…
-
5
votes1
answer169
viewsCommon predecessor in a graph of commits
I ran into another interesting problem during an interview. Unfortunately I’m also not sure I found a great (or good enough) algorithm. I thought to share to see if anyone knows a classic solution…
-
5
votes1
answer1582
viewsHow does authentication work in a stateless Restful environment?
My question is this:: Imagine 3 Tomcat servers (S1,s2,S3) and all 3 servers connect to a single sgbd server (s_bd1). The three Tomcat servers run an application that is of Restful and stateless…
-
5
votes1
answer905
viewsJava use library . DLL
I’m having trouble creating the java interface, because I can’t understand the header of the function in C. Example Header function C: CMOEP_API char * CALLCONV CMP_GetLastError( ); Now in java I…
-
5
votes2
answers4323
viewsHow to update BD sqlite java android
How do I add a column in the database of my android java application without losing data from the current database? My code: public DataBaseHandler(Context context) { super(context, DATABASE_NAME,…
-
5
votes1
answer812
viewsLoad objects related to @Onetoone
concerning the doubt that I have is basic, but it is taking my sleep. I have an entity in which I call Destination. In the Destination entity I have several relationships of the type @OneToOne with…
-
5
votes1
answer754
viewsWhat makes the for and what makes the brackets in an array?
I asked for help on some forums in an old game programmed in java, I understood the logic, but did not know how to apply it (which commands to use, and how to use), and I saw the use of Arrays.…
-
5
votes3
answers5197
viewsDefinition of EJB
Forgive me for the general subject, but I have been researching for some time in various places and I have found nothing that would explain satisfactorily what an EJB is and what it is for. I am…
-
5
votes1
answer1659
viewsHow to handle security in a REST application with Spring?
I would like to know how I could treat the security of a stateless REST application with Spring. Imagine that no user can access any content from /app/content if you have not identified first. There…
-
5
votes1
answer961
viewsCustom auto increment
I have to generate an auto increment of the type "000"+id, but I can not get to something concrete, my base is this below, I wanted only a light even of how to do, I do not need the answer itself.…
-
5
votes1
answer2723
viewsHow to change the font color of a Jtextarea?
All over the internet I just found people wanting to know how to stylize part of the text and being "redirected" to JTextPane, then there are no answers to my question around. So there you go: I got…
-
5
votes3
answers369
viewsStringbuffer.equals and String.equals difference in Java
The behaviour of the method equals class StringBuffer Java is different from equals class String? If yes, how would I overwrite that?…
-
5
votes2
answers1540
viewsJtextarea receives the append but does not display the text
I’m having trouble using a Jtextarea. I need that every time something happens on my system, information is added in real time. However, he appears nothing. I’ve tried using the setText() and the…
-
5
votes1
answer1101
viewsHow to make a Listview with components next to the text on each line?
Several current Androids systems have menus like the one in the example below: Notice that anywhere I touch my finger in the blue area under "Access my location" it turns on or off the switch and…
-
5
votes1
answer576
viewsHow/When to Close Hibernate Session?
I have an error after closing Hibernate Session public String listarTodosClientes() { session.getTransaction().begin(); List<Cliente> lista = session.createCriteria(Cliente.class).list();…
-
5
votes2
answers7594
viewsSend objects via socket
I have a chat that exchanges messages (String) to each other. Everything is working correctly. However, now I want to start sending objects via Socket, like for example, a class that has some…
-
5
votes2
answers1174
viewsInstantiating an Object with a different reference
I’m learning polymorphism in Java, but I’m having some doubts. public class Animal { int numPatas; public void fazerBarulho() { // Código do Método } public void comportamento() { // Código do…
-
5
votes3
answers456
viewsInfinite object?
I ended up doing something that made me curious: I created a Cao class to follow: public class Cao { String nomeDoCao = null; Cao caes = new Cao(); public void setName(String name) { nomeDoCao =…
-
5
votes1
answer120
viewsIs it possible to call the Internal (no visibility operator) method from a class inherited from another package?
Problem I’m trying to create some extra behaviors in some native Android components. For that I am creating a class above the Android component and rewriting some situations I intend to have a…
-
5
votes2
answers3756
viewsHow to save the path of an image in the Database?
I’m using JDBC and picking up an image to save in the database. However I want to save the image in the hard drive and save in the database only the way (path) hers. I wanted to know which is the…
-
5
votes2
answers639
viewsHow to get all paths of a Jtree?
How can I get all the paths of a JTree including the nodes which have parents other than root? root exemplo1 exemplo1.1 exemplo2 exemplo2.1 If I do something like that: for(int i = 0; i<…
-
5
votes3
answers8755
viewsWhat is the best way to replace a character in a given String position?
I need to replace a character at a certain String position(). Example - Swap character[21] with 'X': String Original = 01078989469150999134B B 2116456 Modified String = 01078989469150999134B X…
-
5
votes1
answer155
viewsOptimized approach of checking if there is a certain entry in Windows hosts file
I have a Java web application with Applets that access services on the web. These services are accessed through a specific hostname (example: services.webapp.com.br) configured in the application.…
-
5
votes2
answers1147
viewsDifferences and use of RMI, Socket and JPA
I am new in java and would like a help to understand better RMI, Socket and the JPA, and better understand their utilities and when applied, because I don’t see much to choose between them. I did a…
-
5
votes2
answers458
viewsHow do I move the A context session to B context within Tomcat 05
Try two applications made in Java using Tomcat 6 and are in different contexts but one interacts with the other, by being integrated, I need one to be able to pass their session to the other…
-
5
votes2
answers2053
viewsPass parameter without specifying the type of variable to receive in the function
I’m creating a Java function that returns the type of the variable and as such, since I’m trying to figure out its type, I have no way to tell the function what type of variable to expect. What I’m…
-
5
votes2
answers1286
viewsMultiple Persistence Units with Spring Data
You can create multiple Units persistences by connecting to separate databases in the same JPA application using Spring Data? For example. I have an application that will run in Mysql normally.…
-
5
votes1
answer419
viewsProblems using Java classes in Oracle Database
I’m having trouble using classes Java a little "complex" in the Oracle. When I use a simple class, as an example below: CREATE JAVA SOURCE NAMED "Welcome" AS public class Welcome { public static…
-
5
votes2
answers3052
viewsTry and Catch continue running (after Exception)?
How I put a block try and catch p/ continue the loop for, even if it does arrayindexofbounds and among other Exception? I put and it runs but the output of "m" does not print anything after! for…
-
5
votes1
answer1469
viewsHow to make a site multilingual and identify the country of origin?
I am developing a site in Javaee and would like it to be multilingual (at least English, Portuguese and Spanish). But I would like to know how large websites, such as Facebook, for example, do to…
-
5
votes2
answers120
viewsWhy do certain services still depend on the Java plugin?
Banks, digital certificates, government service websites still depend on the plugin java. The idea of Java, "write once, run anywhere" is not always true. Many services still have platform-specific…
-
5
votes1
answer1211
viewsHow to include a jar when running a Java file per command line
Every time I run the program I need to call a specific library, which in this case is /home/usuario/Programas/weka-x-x-x/weka.jar, but every time I run the program, I have to include the following…
-
5
votes2
answers116
viewsHow to make readable the code that uses String properties?
I have a string that uses parts of another string, how to make this code more "clean"? Since it is very difficult to understand. String sessionHash = dirPath.substring(dirPath.substring(0,…
-
5
votes2
answers11135
viewsException vs Runtimeexception, when using one or the other?
I was with that doubt, and when I was made aware of it another came to me, which I would like to be clarified. What’s the difference between Exception and RuntimeException? When to use Exception or…
-
5
votes2
answers3987
viewsDouble formatting in Java
I have the following value 1234.0000. I would like to format to the following output: 1.234,00. There may be cases I’ll use as well 1.234,0, but I believe that making for the first case the others…
-
5
votes1
answer727
viewsHow to create a value pair within a Java Map
It is possible to create a Map in Java using the concept of pair that exists in C++? I have tried to use it in the form below, however, I cannot assign values to my map. Map<String,…
-
5
votes4
answers599
viewsProgram Locking in While
I’m working on a project and I’m having problems with the same, this program I’m posting is similar to what I’m working on. The problem is this: it arrives in while, the program does its function,…
-
5
votes2
answers7034
viewsHow to play sound in a java program?
I need to make a program in Java, where the user puts the password and it is displayed on a TV monitor, this program will be used in a restaurant, so that when the order is completed is issued on TV…
javaasked 9 years, 7 months ago T Fernandes 51 -
5
votes1
answer4346
viewsHow to sort alphabetically and numerically the same list?
In my college work I must make a list of the kind of class I created and I must sort it in two different ways, one by alphabetical order and the other by average score. Also other information is…
-
5
votes2
answers189
viewsWhy does Netbeans suggest improving the for?
When I was doing this for Netbeans Showcased That Lamp of Tips to Improve Code on the Line of for. The suggestion was to reverse the condition. Follow the code: Before of improvement: for(int j = 0;…
-
5
votes0
answers714
viewsProblem loading database image with JSF
I’m having a problem loading images from the database with JSF and CDI, below is the code for a better understanding of the problem. <ui:define name="titulo">Detalhes Anuncio</ui:define>…
-
5
votes1
answer5783
viewsConversion of Dates to Mysql database
Hello! Well, I’m using xhtml and primefaces. On my xhtml page, I have a field for date and use the converter to save in the database, I have a problem with the day. If I want to save 30/04/1989 In…
-
5
votes2
answers179
viewsObject type for Time type data (Ex: 1 min 56 seconds) in Android/Java?
I need to work with times, such as a chronometer (not my case), which at the end of its execution would have to keep its value. So I thought of some possibilities like: java.utils.Date: only that…
-
5
votes2
answers6790
viewsCan an int equal null?
After seeing a question related to this, and many college colleagues with doubts linked to it, I decided to ask this question. The guy int may equal to null?…
-
5
votes1
answer697
viewsWhat are the packages?
I’m starting with Phonegap and creating a project has the following structure: phonegap create helloWorld com.dominio.pasta HelloWorld But I never understood about this package. Is it a reverse URL?…
-
5
votes2
answers899
viewsGraphs: the longest path
Well, as a college job, I have to create an algorithm that, given a certain file with x is able to verify which is the largest sequence of numbers which, on the basis of 6, comply with the following…
-
5
votes4
answers12786
viewsHow to create a java class?
I would like to know how to create a class in the java, how to use this class in the main program and how is the variable created in this class.
-
5
votes2
answers565
viewsWhat kind of tests can I still do on that code?
I’m doing a sequence of tests in a simple bank application, but I don’t know what kind of test I can do on this system to cover 100% of the code, it’s only covering 61%. I’ve done all the tests with…
-
5
votes3
answers4457
viewsCalling Java application via PHP
I created a Java application here in my company but they want to call this application in Java via a site made in PHP. I wonder if it is possible to make a PHP code that calls a Java application, no…
-
5
votes2
answers6174
viewsHow to count the frequency of each letter in a string?
I need to count the relative frequency of each letter in a string (only letters), without considering the spaces, without differentiating between upper and lower case and without differentiating…