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
answer777
viewsError changing table SQLITE - in such column
I included a new column in a table. I reinstalled the application and at the time of saving the data there is a message saying that there is a pathImage column, in my case in the clients table. I…
-
2
votes1
answer389
viewsHow to find the JVM port in linux?
I have a linux server running a JRE 1.7 and I need to use Visualvm to monitor the performance of applications running on it. Visualvm uses JMX to connect to the linux host but it expects something…
-
2
votes2
answers1743
viewsJdbctemplate - How to commit and rollback?
i am working with a Desktop application and use spring to realize my Inserts in the database. The object I’m using is Jdbctemplate, which has the datasource encapsulated within it. I would like to…
-
2
votes3
answers321
viewsWhy give new in class attribute?
I am leaving C++ for JAVA and would like to know why to give new already in class attribute? public class ExemploPES2 { class y{ int value; } class x{ private y nova = new y(); } I do not understand…
javaasked 7 years, 4 months ago Sergio Souza Novak 513 -
2
votes1
answer47
viewsError using date type on android
I have this code: String dt = "2017-01-04"; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { sdf.parse(dt); } catch (ParseException e) { e.printStackTrace(); } But when I use dt , in…
-
2
votes1
answer2663
viewsHow to calculate the logarithm of a number in any java database?
I would like to know how to calculate the logarithm of a number on base 2 and on any other basis. I know that in java you can calculate the logarithm of a number in base 10 using the function…
-
2
votes3
answers5297
viewsJDBC connection to Mysql
I’m learning how to develop java and I’m trying to advance my studies to understand how to make a database connection, but there’s some problem that I’m not able to identify. Below the error written…
-
2
votes1
answer717
viewsDelete entity and all its relationships Hibernate
I have the entity Fatura who has a relationship OneToMany with the entity Item. When I try to delete an Invoice I have the following error: Caused by:…
-
2
votes1
answer183
viewsHow to encrypt in the Java Web project
Can someone pass me some material with the safest way to make the security of a system? I want to put this in the user registration in my JSF project with Primefaces 5.1 for when it is registered…
-
2
votes1
answer183
viewsSelection Sort - Is that correct?
I implemented a logic of Selection Sort and would like to ask if it is correct. Because at the end of the process the result is expected, but went to make a real proof and found several algorithms…
-
2
votes1
answer741
viewsHow to leave only one edge on Jtextfield?
I wonder how to leave only one edge on one JTextField, similar to data entry when logging into Gmail, that is, with a border at the bottom.
-
2
votes2
answers849
viewsHow to pass a float without loss of value to an integer?
I have a float variable that can contain any number in it, I need to test if it fits an integer without losing values. I thought to use some test to see if the numbers after the comma are 0’s or…
-
2
votes1
answer363
viewsHow to do date validation?
How to validate the date as the date of birth? Can not put the date in the future. data.addTextChangedListener(DateUtils.insert("##/##/####", data)); mData = data.getText().toString();…
-
2
votes1
answer87
viewsHow to create bookmark in logback?
I am trying to create a bookmark inside my logback appender and could not. My code is <appender name="ErrorFile" class="ch.qos.logback.core.rolling.RollingFileAppender"> <!-- Support…
-
2
votes1
answer71
viewsDoubt with Java EL code snippet
I’m studying a code and I don’t understand this part of EL: <c:choose> <c:when test="${not empty pedidoMesa}"> Pedido: ${pedidoMesa.id} ${pedidoMesa.nomeCliente} </c:when>…
-
2
votes1
answer376
viewsError String to Int Conversion
I’m doing a simple program, where it reads a file . csv (Excel) and then generates a graph of it. However I am having problems when converting String to Int. Below is the code of the Button event:…
javaasked 8 years, 9 months ago Marco Antonio 95 -
2
votes1
answer7956
viewsHow to work with Log in Java?
I need to make a condition based on the Log of my Java project. Ex: Enquanto(TextoDoLog == "PalavraTal"){ faça algo; } But I don’t know if I have to create some class, or method, how to handle it.…
-
2
votes1
answer2691
viewsHow to open a window inside a main frame?
I’m doing a show and I’m creating the layout manually with swing using GridBagLayout and GroupLayout. I wonder how to open a window inside the program I’m doing. For example: When the user clicks…
-
2
votes2
answers1621
viewsNon-static method cannot be referenced from static context?
I was watching the programming class in java and basically the business was to calculate the total area of a house with a pool, however, I’m having difficulties. Basically I separated everything…
-
2
votes1
answer207
viewsTable Hash with quadratic method
I am implementing a hash table with quadratic scanning method. My question is about the position 0 of the vector used for table implementation. Follow the code below: public boolean inserir(Pessoa…
-
2
votes1
answer276
viewsReturn array of integers except 0. How do I do?
The method takes two numbers per parameter, and returns one array with the odd numbers between these two numbers. public static int[] oddNumbers(int l, int r) { int odd[] = new int[r]; for(int i=0;…
-
2
votes2
answers1483
viewsCompress image size
How to compress the size of an image so that it is smaller ? public void onCaptureImageResult(Intent data) { Bitmap thumbnail = (Bitmap) data.getExtras().get("data"); ByteArrayOutputStream bytes =…
-
2
votes1
answer866
viewsFullcalendar fill events by JSON
I’m putting the Fullcalendar component in my Java application. I’m having trouble loading events into the calendar. How do I read json inside my js file? Follow the code below: JS file:…
-
2
votes1
answer1768
viewsHow to insert the size of an array as per user input?
How do I enter, asking the user through the class Scanner, the size of the matrix and it tells me the column and row numbers you want, and then print the values, without using methods? I tried but…
-
2
votes1
answer740
viewsHow to make Hibernate read a table in a Mysql database and write to another table in Postgresql?
I need to consult a database in Mysql and take a table from there to write to a database in Postgresql by Hibernate/JPA. I set up the persistence.xml as follows: <?xml version="1.0"…
-
2
votes1
answer420
viewsHow to load a URL that is inside a . txt from the Web View?
The thing is, I’m making an app that’s kind of webbrowser. In this app, I have a url written inside a . txt, and I need to load this URL into my Webview. Follow what I’ve already done: NOTE: I can…
-
2
votes1
answer115
viewsRelationship between Hotspot and JVM, JDK/Openjdk?
What is Java Hotspot and what is its relationship with JVM and JDK/Openjdk?
-
2
votes1
answer282
viewsHow to assign textview return to a string?
Well I am beginner in Android/Java, I wanted to do the following take the result of a textview that is caught through the scan Arcode and play in a string to make a list of results taken by the scan…
-
2
votes1
answer153
viewsHow does the process of accessing a database work?
I started studying databases and to access a certain database with JDBC a driver is required for each DBMS (Mysql, SQL Server, Oracle), and the access is done on disk, but how is this process done?…
-
2
votes1
answer1273
viewsHow to make part of the Jlabel text bold
Is there any way to leave only a portion of the bold text of a Jlabel? For example: label.setText("apenas esta parte em <b>negrito</b>"); But this snippet of code prints the 'b' on the…
-
2
votes1
answer115
viewsModify the range of a Jslider
In my project I have a Jslider, its minimum value is 0 and its maximum value is 10. I would like to modify it so that its interval is two in two numbers, so that it is only possible to select/show…
-
2
votes2
answers759
viewsHow to give Restart in an Activity?
I want to re-start my activity without the help of buttons, I want it to restart automatically within a while. How do I do this?
-
2
votes2
answers512
viewsJSON to XLS in java
Is it possible to turn a JSON into XLS with java? I’ve done an algorithm that writes JSON to CSV, but not XLS. If you can post libraries or examples.
-
2
votes0
answers2786
viewsHosting tips for Java application using JSP, Hibernate, Mysql and Tomcat that serves data for Android application
Guys , is the following. I developed an Android application where it is fed data coming from a remote database (Mysql) via Restful. On the server side, I developed a java application using JSP and…
-
2
votes2
answers58
viewsWhy is the condition of j never satisfied with "||", and why is i satisfied with "&&"?
package aulas; public class Aula{ public static void main(String[] args){ for(int i = 0, j = 0; i < 100 || j < 50; ++i); //Quando troco o operador lógico para && é…
javaasked 7 years, 3 months ago Bruno V. Martins 35 -
2
votes2
answers373
viewsRemove spaces from a String array
How to remove spaces (not all spaces, just the beginning and end) from all indexes of a Java String array?
-
2
votes1
answer320
viewsGraphic Primefaces with Consultation by Month and Year
I am trying to query a chart per month and year that when I click on the chart series it will display the records belonging to that path. When doing the search the chart is mounted correctly…
-
2
votes0
answers89
viewsLog4j is not generating log backup
I have two jar on the same classpath, so they are using the same log4j.xml. The project in which the xml is, makes the roll correctly, but the other project does not. I configured the xml to…
-
2
votes2
answers2116
viewsTomcat V8.5 not booting, error: Child container failed During start
I’m doing a college paper, a simple crud with JSF2, Hibernate, Primefaces and CDI. However at the moment I will initialize the project in Tomcat I have the following error: GRAVE: A child container…
-
2
votes2
answers428
viewsMultiple sorts with Arraylist
I have a question. I want to order the Arraylist person in different ways. <%@ page import= "java.util.*"%> <%! public class Pessoa implements Comparable<Pessoa> { String Nome;…
-
2
votes1
answer691
viewsHow to get values from two html selects in javascript?
Basically I have the code below: var associar = $("#associar"); var desassociar = $("#desassociar"); var permissoes = $("#permissoes"); var minhasPermissoes = $("#minhasPermissoes"); var gravar =…
-
2
votes3
answers883
viewsValidate whether INSERT was successfully executed or not (JTDS)
I would like to know a form of validation to know if the Insert was successfully executed, I have no idea how to do this because the execute() method does not return anything!!! Connection…
-
2
votes2
answers5103
viewsError to connect to sql server 2014 database with java and connection string problem
I put the jar and made the build path . I’ve been trying for a while to connect with the microsoft bank but gives this error: Exception in thread "main" java.lang.RuntimeException:…
-
2
votes1
answer434
viewsCheck Connection to bank and validate to user
I would like to know the following: I am trying to make an application that makes several connections to the database. I always wanted to check the connections and if the connection is not available…
-
2
votes2
answers763
viewsRecover the value of an attribute of a generic object in Java
I’m making a system where I read Java objects of different types of XML files. So I don’t have a single object type and consequently I don’t know its attributes or methods. I would like to perform a…
-
2
votes1
answer346
viewsArray of Boolean for Integer
How can I transform a Boolean array, boolean[] bits in his Integer correspondent? I have a function that does exactly the opposite, but I didn’t understand it enough to be able to reverse it. int…
-
2
votes1
answer467
viewsError creating login screen with Javafx
Good evening guys, I’m wanting to implement a login screen with the following fields, but it does not appear the other fields, appears the user field and password Forgot the login click…
-
2
votes1
answer504
viewsView Splashscreen with progress while Jframe is loaded
I have an app made on swing, and I’m trying to add a SplashScreen in it. I managed to make the class SplashScreen work normally, but I’m not able to synchronize the loading of Jframe in invokeLater…
-
2
votes1
answer444
viewsRead the txt and return it all in a Java String
I have this code to read one txtand would like to return later a string with the txtall copied , but this algorithm it just read the lines and goes showing how to return all the content it read in a…
-
2
votes1
answer689
viewsWhat to do so the service is not finished by Android?
I have a service that runs in the background to pick up the location and go recording in a text. The service is started together with android through Broadcastreceiver. Works perfectly, but after…