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
answer577
viewsHow to communicate between java in Prolog?
Good morning! I need to develop an expert system as a college job. I thought of doing it using java to create the interface and Prolog as the engine of inference and basis of facts. But the links I…
-
2
votes2
answers1512
viewsConvert a date and send to the bank
The code is all working, the problem is the date, I want to take the date of a jformatedtextfiel ##/##/####### in the case txt_data and send to the bank, I’m in the java basics, I’ve been hooked…
-
2
votes2
answers2043
viewsReading String until you find a certain character
I can receive data like: 232321 or dwd But sometimes a "+" can appear between the Strings. How do I extract only what comes BEFORE this character? If so, I have an entry like "432d+321" would stay:…
-
2
votes2
answers145
viewsError compiling code with import java.util.Random; Random.nextInt()
I’m studying the Java programming language and I found an obstacle, by some chance I can not compile this code import java.util.Random; public class Random { public static void main(String[] args){…
-
2
votes1
answer1013
viewsOpen multiple windows from the same application without accumulating icons in the taskbar
I wonder how I could create frames in java, without opening so many windows in the windows taskbar. For example when I go to the menu and click on client registration, address registration, address…
-
2
votes1
answer194
viewsValidate increasing and decreasing numbers with regex
I need to create a regex for increasing and decreasing number validation as an example: Repeated | increasing | Decreasing 000000 | 012345 | 987654 111111 | 123456 | 543210 [09:30:16] William…
-
2
votes1
answer90
viewsError returning list to Activity
I made an implementation on Android to return all bluetooth devices (paired and connected) in a list. It all worked properly to return the paired devices. For connected also worked, if I go by debug…
-
2
votes1
answer727
viewsShow PDF on the page via Servlet
Hello, I am developing a web application using Servlets and Jsps. I still don’t have much experience with it. My page contains a button that downloads a BD file and a <object> HTML to display…
-
2
votes1
answer381
viewsCheck if GPS is enabled in all versions of Android?
I use this code to check if the GPS is enabled to display a dialog: LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); boolean GPSEnabled =…
-
2
votes2
answers175
viewsNullpointerexception error, where is the error?
I wanted to know where the mistake is. I read that the mistake NullPointerException is when we try to access a variable that wasn’t initialized, I just didn’t find this error in my code. import…
-
2
votes1
answer161
viewsDoubts about security in SSL communication of Sockets
I wonder if this communication between the sockets is safe. From this code I can safely exchange information? I am also doubtful to understand how the Sslcontext class works (it is not in this…
-
2
votes2
answers908
viewsMap of Google Maps does not open after the app launched
I’m using the Google Maps Android API, but it’s not working when I send the app to Google Play. In debug it works normally and when I run the application by Android Studio too, but when I launch the…
-
2
votes1
answer57
viewsDifference between List and and Return in Entity
Hello, I am with a doubt when I will take the data of an SQL query, there is the possibility to pull by list and by Entity, which is would be the "most correct" or the usability of each? public…
-
2
votes0
answers120
viewsVery slow Httpurlconnection implementation when running
I’m using the class HttpURLConnection to make the connection to a site that returns a JSON and I did the following encoding: URL url = new URL("http://hmkcode.appspot.com/rest/controller/get.json");…
-
2
votes1
answer957
viewsHow to use variables declared on other JSP pages after include?
I have a jsp page with only two includes in the whole code: <%@ include file = "../_global/prefixos.jsp" %> <%@ include file = "../_global/testaProfessor.jsp" %> In prefixos.jsp I have…
-
2
votes1
answer339
viewsGet the current page name with JSF 2
I am using JSF 2 and need to get the name of the current page, how can I do?
javaasked 8 years, 3 months ago Jeremias Santos 403 -
2
votes2
answers1368
viewsHow to get the coordinates (X and Y) of a click on an imageview?
I’m making an application that has an image that occupies the whole ImageView, and when the user clicks at some point on that image, the X and Y coordinates corresponding to the image are obtained…
-
2
votes1
answer121
viewsGenerating new objects using existing objects
I’m having a hard time doing this. Supposing I have two objects of the kind Person, which has the attributes name and employment. P1 (name=John, job=Taxi driver) P2 (name=Maria, job=Programmer) Then…
-
2
votes2
answers268
viewsSet value for a cookie
I intend to change a cookie value, I’m using: public static void main(String[] args) throws Exception { URL url; HttpURLConnection conn; url = new URL("http://google.pt"); conn = (HttpURLConnection)…
-
2
votes2
answers4863
viewsHow to create a method with optional parameters in pure Java?
How I create a method that does not need to enter all parameters? Ex. There is a method that asks for 5 parameters. But I intend to use only 2.
-
2
votes1
answer397
viewsPrimefaces p:datatable without the "No Records found" message?
And I have a p:datatable: <p:dataTable var="ind" value="#{logIndPersistBean.list}" paginator="true" rows="10" id="table" rowStyleClass="odd-row, even-row"> <f:facet name="header"> Lista…
-
2
votes2
answers2211
viewsPrimefaces p:datatable changing default message "No Records found."?
And I have a p:datatable: <p:dataTable var="ind" value="#{logIndPersistBean.list}" paginator="true" rows="10" id="table" rowStyleClass="odd-row, even-row"> <f:facet name="header"> Lista…
-
2
votes2
answers2446
viewsSelect JPA and Hibernate
I have five entities (Quotation, Sector, Partner, Items and Items), where the user will select a quotation and sector and the list of all items related to this sector will appear, along with the…
-
2
votes3
answers1005
viewsRecognition of sound patterns
I would like to know about the existence of some Android/Java API for sound pattern recognition. Example: Bird singing, sound is given as input, and the application would return to which bird this…
-
2
votes0
answers308
viewsConvert ASCII Database Postgresql return to UTF-8 in Java Ksoap
Have app Android that consumes from a webservice where the database is Postgresql and the ASCII type. When I try to print the string returned in the app he defaults the lyrics with accentuation, for…
-
2
votes2
answers1125
viewsTables are not automatically created by Hibernate in Mysql
Hibernate cannot create the table in the database already created (drogaria_teste). Below is code. Hibernate.cfg.xml: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE…
-
2
votes2
answers614
viewsHow to get current directory of a web application?
I need to know how I get the current directory of my application because I need to save some PDF files. I have tried a few times, but without success. Can anyone give me a light? Look how I’m doing:…
-
2
votes2
answers58
viewsI’m having a nullpointer error and don’t know how to fix
The code I’m using is this: public ForumGroups getMainGroup() { if (Constants.SQL_ENABLED) { int lowest = -1; ForumGroups g = null; for (ForumGroup group : forumGroups) { if…
-
2
votes1
answer785
viewsComposite key problems in JPA
Hi, I’m a little young with JPA and I’m having problems with a composite PK. Follows the class Aluno: @Entity @Table(name = "Aluno") public class Aluno { @Id private String ra; @Column(length = 50,…
-
2
votes1
answer292
viewsCamera appears with black screen. Error fail to connect to camera service
I would like to open the camera, but without the buttons that appear normally, I would like to add my own buttons and assign functionality to them. I looked it up, but I couldn’t find any answers.…
-
2
votes2
answers533
viewsAlertdialog from another class
My problem is this, I have a Activity calling methods of a common Java class for performing operations. Now I have arisen the need for one of these methods to be a AlertDialog, I have already…
-
2
votes0
answers60
viewsThe method exceeded the limit of 65,535 bytes
I have a JSP file and any line of code I insert, it displays the following error: The code of method .. is exceeding the 65535 bytes limit. The problem is that I am using Opencms, which is based on…
-
2
votes1
answer863
viewsModel attribute unit tests in spring boot application
Good afternoon I don’t have much experience with unit testing. I’m testing controllers in a spring boot application, but I made some error in testing model attributes, which apparently isn’t even…
-
2
votes1
answer193
viewsHow to disable scrollView interaction on the user screen?
On the screen, the user should not be able to touch the Scroll, His drive I’m doing all by code this way for example: Moving: public void move(View v){scroll.scrollTo(160, 0);} I’m looking for a way…
-
2
votes3
answers77
viewsClass instantiation
Hello, I created a vector class and a method to add its elements. However, in the instantiation of the same, not returning, can help? public class TesteVetor { public static void main(){ Vetor…
-
2
votes2
answers483
viewsWebservice + SOAP for android
Good morning, I created a web service with Soap and tested in the tool Soapui. In this tool works cool. In android to using Ksoap and when I have the data listed in Logcat it is popping an…
-
2
votes1
answer296
viewsVariable as Java Method Argument
Do you pass a variable as an argument of a method not its value, but the instance itself, every change made in the argument applies the variable? Just like it works in Javascript?
-
2
votes1
answer53
viewsDoubt "Maven-archetype-webapp" template
I’m a beginner in development with Maven and I’m having some doubts. Next, I would like to create a Java web application, so I started running the following command: mvn archetype:generate…
-
2
votes1
answer575
viewsHow to run a routine periodically automatically on a java server like wildfly10
In a java web system, I need from time to time that the application server runs a routine automatically (Scheduler). The problem is that I don’t even know where to start, that is how to make the…
-
2
votes1
answer216
viewsIn an Activity, first open the onCreate method or class constructor?
In a scenario where you have an Activity with a constructor (public, of course) and the onCreate method which is part of your life cycle. Which of the two will be executed first?
-
2
votes1
answer252
viewsApache in different programming languages
What’s the difference between the Apache server for PHP (Wan) and the Apache Tomcat Web Container?
-
2
votes1
answer165
viewsHow to get the final JPA SQL using Namedqueries
How to get the SQL that is running by JPA when we use a createNamedQuery. I would like to have SQL run to understand where the query problem is below: Call from the Namequery EntityManager em =…
-
2
votes1
answer1802
viewsHow to create a text file on Android?
I’ve looked for several examples and scripts on the internet and even here in stackoverflow but still could not create a text file on android, the last code I tried unsuccessfully was this: How to…
-
2
votes0
answers635
viewsHow to fix encoding problems on a web application page?
I am developing a JAVA application with the Spring framework v3.1.0, however, when trying to access a page shows error of encoding: Evolu㧠How to solve this problem? I found several ways, but none…
-
2
votes1
answer580
viewsSpring @Scheduled with internal transaction triggering Propagation error
I am trying to run a service that is based on running by cron with annotation @Scheduled, but every time a database transaction needs to be opened within the annotated method with @Scheduled receive…
-
2
votes1
answer1072
viewsCalculation of a high value to an exponent b
I must create an algorithm that calculates a value a high to a exponent b. It is an exercise that cannot use Math.pow. I did the algorithm and when I put negative exponent the result. public static…
-
2
votes5
answers1896
viewsChange Button Background
How can I change the background of a Button click on it? For example: I have the shape01 and the shape02, for default the Button this with the shape01, when clicking on it I need to change to the…
-
2
votes2
answers1439
viewsWhat is the meaning of this line in Java?
I did not understand the following line of the code below: ret += this.elem[i]+(i!=this.ultimo?", ":""); What are the meaning of these operators i! , ? and : { String ret = "{"; for (int i=0;…
-
2
votes1
answer184
viewsClone an object (deep copy)
Good evening. I’m working on a program that writes a text. Basically it consists of a Text object which is a list of Paragrafo objects, which is a list of Sentences objects which is a list of Words…
-
2
votes0
answers22
viewsWhat is the function of << (two Less than) in Java?
I have the following method: private static String encode(long number){ StringBuilder builder = new StringBuilder(); number = number < 0 ? ~(number << 1) : number << 1; while (number…
javaasked 8 years, 2 months ago Thiago Luiz Domacoski 7,310