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
-
6
votes1
answer64
viewsHow does the creation of a proxy work under the table?
I’ve had a lot of fun creating interface proxies in Java. For example, the following proxy was required on Sqldroid to run version 5.2.4 of Flyway (and also to catch the path of the file created by…
-
6
votes1
answer90
viewsUsing static factory methods instead of constructors
I’ve been doing some research on this subject after I read in Joshua Block’s book, Effective Java, Item 1, about the use of static factory methods rather than building builders. There in the text he…
-
6
votes1
answer2441
viewsApplication does not work after generating . APK
I am facing a problem when trying to generate an app apk developed in Android Studio. After generating the . apk to install the app on other phones, the app is installed but does not open. On mobile…
-
6
votes2
answers140
viewsHow do I access getters and sub-class setters?
In this application we have the class Automóvel: public class Automovel { private String marca; private String matricula; private String anoConstrucao; private Motor motor; private int preco = 0;…
-
5
votes1
answer736
viewsJcombobox does not allow item change
I have a JComboBox which allows selecting only the first item clicked, in case I want to change selection it does not allow. In the jPanel There are two other combos that are identical with the one…
-
5
votes2
answers2102
viewsHow to compare Date class to System.currentTimeMillis() in Java?
How to compare if a Date object, for example "2014-01-29 00:00:00" is larger than the date of the current system, for example System.currentTimeMillis() in Java? I would like to do something like…
-
5
votes2
answers252
viewsSlideshow with images from Urls
I was developing a slideshow loading images from Urls I found a library developed by a Russian, the Universal Image Loader, however this slideshow will be used in the application in the version of…
-
5
votes1
answer1387
viewsDisplay a message when Listview is empty
I have a Listadapter that extends a Basedapter that works perfectly. When it is empty I wanted a message to appear any. Where to implement this validation?
-
5
votes1
answer164
viewsFacebookoperationcanceledexception error in Facebook SDK Friend Smash example game
I followed the tutorial from Facebook SDK to implement the game Friend Smash. In Activity Home has a button to view the Scores. However, when clicking it shows a connection error on the screen:…
-
5
votes2
answers704
viewsComponent pe:Masterdetail does not work on dynamic pages
I’m developing a web app that aims to work like Facebook. During the navigation the page is not reloaded, loading via AJAX only the central content. I’m using Primefaces 4.0 and Primefaces Extension…
-
5
votes2
answers1144
viewsChange Arraylist nodes
If I have a ArrayList<Integer> listInt for example, suppose in this ArrayList have: int a, int b, int c; //a = 2 b=3 c=4 and then I change the value of a, b and c for example to a=1 b=2 c=3…
-
5
votes2
answers258
viewsApp crashing when an image is selected
I am trying to get an image using an Intent, but when I select the image, my application closes immediately. This is my current code: private void capturarFoto() { String nameFoto =…
-
5
votes1
answer7034
viewsTake Edittext value from a layout passed as a parameter to a Alertdialog.Builder at the click of the button?
I use Layoutinflater in my view - View view = li.inflate(R.layout.alertdialog, null); I created a Alertdialog.Builder Builder setting for it the view, and the buttons positive and negative. My…
-
5
votes2
answers927
viewsObjectoutputstream only saves the first object
I’m trying to manipulate a Byte file with Java. In the writing of the file I have the following code: FileOutputStream fos = new FileOutputStream("files\\Produtos.dat",true); ObjectOutputStream oos…
-
5
votes2
answers756
viewsHow to use arrays in Java?
It’s a very beginner question (I’m new to Java, I came from C++). I have to do a program that takes 4 grades from 10 students, but when I go to work with the "pointers" (arrays), my program returns…
-
5
votes1
answer3767
viewsdynamic path out of context in Servlet
To get the dynamic path within the project is easy, just run the code : String path = this.getServletContext().getRealPath(""); Here is returned:…
-
5
votes1
answer925
viewsHow to determine which HTML file should be displayed as input in Jersey?
I’m trying to find a way to provide a correct entry page in Jersey. A login page when there is no logged in user, otherwise I should display another homepage that will call Restful services…
-
5
votes1
answer384
viewsProblem with Java timer
Explanation: I have a component JTextField that would be a regressive counter, but when I use the ActionListener in this way: public static ActionListener alredBGolem = new ActionListener() { public…
-
5
votes1
answer154
viewsGetting Factory null in spring sessionfactory with configured resource
The name of the class containing the SessionFactory is DataProvider and has the following implementation: @Resource(name="sessionFactory") protected SessionFactory factory; protected Class<E>…
-
5
votes1
answer933
viewsHow to override variable defined in POM with specific value at the time of mvn execution?
In an environment with multiple configurations of Web Container sometimes we need to correctly point the deploy directory of the application that may be in different directories depending on the…
-
5
votes2
answers8082
viewsMaven how to define JDK version?
Problem: When I create a project maven the project always got the version JDK 1.5, change the JDK version in the IDE when doing a Maven > Project Update he goes back to JDK 1.5. The archive…
-
5
votes2
answers2110
viewsHow to index and search for files in Lucene
I am trying to generate a Java file indexer with the help of Lucene. I followed this guide from iMasters and tried to adapt to the version 4.7.0, the problem is that at some point the search is not…
-
5
votes2
answers3548
viewsHow to check if a directory exists in Java?
I’m trying to check if a directory typed in JTextField exists or not. I tried to use Files.notExists() but the first argument must be of the type Path and I couldn’t figure out how to convert from…
-
5
votes3
answers860
viewsExtracting Numbers from a String
I have a string in the following format: 01 - 02 - 03 - 04 - 45 - 86 I need to put these numbers in one array int[6]. What is the best way to do this operation?…
-
5
votes1
answer120
viewsError with super(this) when calling a Java constructor
This is allowed? public Produto(Context context) { super(context, this); } You’re making a mistake : Cannot refer to 'this' nor 'super' while explicitly invoking a constructor I’m trying to make a…
-
5
votes2
answers332
viewsDifferent orientations on smartphone and tablet
Hello, I am developing an app and I need the screen to be in Portrait for smartphones and Portrait/Landscape for tablets. The customer does not want to accept different applications and does not…
-
5
votes2
answers4938
viewsPoint function in calculator (broken numbers)
I created a calculator with Swing and awt.Event, and I have three doubts ! First doubt: to create the calculator I used import with import.javax.swing. * and java.awt.Event. *, when I use *, am I…
javaasked 10 years, 7 months ago Gabriel Ozzy 545 -
5
votes3
answers4187
views -
5
votes1
answer1988
viewsMultiple layouts in one Activity - how to use?
As in this passage: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.addcontact); imageButton01 = (ImageButton)…
-
5
votes1
answer1421
viewsSimulation of TV Remote Control
I am developing a system where there should be the possibility of the user to interact with the program, pressing one or more numeric keys to change the display of multimedia contents (text, audio,…
javaasked 10 years, 8 months ago Augusto Cesar de Sá Nunes 83 -
5
votes1
answer892
viewsHow to create Cover in a Report using iReport
I am using iReport 5.5.2 and have tried in many ways to add a cover to the report, which is necessary but unsuccessful. I tried adding the isTitleNewPage attribute to the iReport Title band, but it…
-
5
votes2
answers3228
viewsQuestion and answer with if and Else in Java
No matter what I say, both "yes" and "yes" just show the ELSE. Where am I going wrong? package saudacao; import java.util.*; public class Saudacao { public static void main(String[] args) {…
-
5
votes2
answers710
viewsStatic string being created with wrong Encode
Hello, When creating a string in a Java class (for example: String t = "Ola Java!"), it seems that the compiler is choosing the 'wrong' encounter to interpret the bytes that are in the source and…
-
5
votes2
answers3778
viewsUsing JSP and JAVA
I’m starting to mess with JSP. But I’ve been using JAVA for some time. I have the index.jsp file which is my page and I have my indexJava.java which is the program itself. I would like to know how…
-
5
votes1
answer394
viewsHow are the standard library functions of different programming languages implemented?
How are standard libraries of different programming languages implemented? For example, stdlib.h, or Java.Swing, how the function is implemented System.out.prinln() for example.…
-
5
votes1
answer158
viewsUse of Spring Security
Guys I’m using the spring security in a project, I was informed that I should take the jdbc driver and put it in the Omcat lib folder for the whole spring process to work properly, because it would…
-
5
votes1
answer915
viewsDifficulties with binarySearch Class Arrays method
I created two arrays one of integers and the other of Strings(objects), but when I used the binarySearch method to know the position of the elements, the return of the positions of the Strings array…
-
5
votes1
answer452
viewsKnow the most repetitive code in a data structure (list)
I’m doing a project in Java of data structures and I have a list simply chained that gets the code, name, sex and course of each person. I only need to validate which code (whole type) repeats the…
-
5
votes1
answer668
viewsDetecting Volume Keystrokes Pressing on Android
I found a palliative solution, which keeps monitoring the change in the volume of the system itself. When the volume decreases, for example, from 10 to 9, the program resets the volume back to 10…
-
5
votes1
answer1179
viewsAndroid app closes as soon as it loads (Noclassdeffounderror)
I installed the Android SDK all right, installed the USB drivers of my Motorola Moto G. It’s all right, so when I run the application directly from Eclipse, it finds my device connected. USB…
-
5
votes1
answer2052
viewsUsing Hibernate to generate tables with H2
I’m developing an application in which I decided to use H2 as an embedded database. It is the first time that I am using this type of database and I am having problems to generate the tables by…
-
5
votes2
answers1701
viewsSelenium problem with get!
What I desire Open a browser using Selenium, accessing a website (e.g..: http://www.google.com) driver.get("http://www.google.com"); and write a search in his text field element.sendKeys("Cheese!");…
-
5
votes2
answers572
viewsPrimarykey, Foreignkey and Unique With JPA
I have the following situation: Student Entity (id and other) Entity Evaluation (id and others) Entity Notaavaliacaoaluno (avaliacaoId, alunoId) I want to transform the attributes valuedId, alunoId…
-
5
votes5
answers13518
viewsHide the keyboard
As soon as the user clicks on one of EditText from my Android app, the keyboard appears, however, it does not disappear when you finish typing and click off it. I would like to know which method…
-
5
votes1
answer329
viewsConvert to String number with scientific format
I have the following number, in scientific notation: 7.89894691515E12 I need to convert it to String, in the common format: 7898946915150 How to do this through Java?
javaasked 10 years, 3 months ago felipearon 715 -
5
votes3
answers1018
viewsSerialize XML for REST API with Correct Accent
I am creating a small read-only REST API service on a client system. It uses Spring MVC to fulfill the requests and the purpose of each request is to return a JSON with certain information to…
-
5
votes1
answer7213
viewsLibraries for communication between Arduino and Android
I am a beginner Arduino programmer trying to make a connection to my mobile phone (Android) and / or my laptop using Java. I’ve done some research and so far I’ve found three examples of how this…
-
5
votes1
answer3064
viewsDifference between null and clear on an Arraylist
What’s the difference between: arrayList.clear(); and arrayList = null; The two do not destroy all elements of Arraylist?
-
5
votes1
answer793
viewsChanging size of Joptionpane.showInputMessage
I tried several methods like setPrefferedSize , setSize with/without pack() but nothing seems to affect Joptionpane code: selectProcess = new JOptionPane();…
-
5
votes1
answer98
viewsPass "visibility" as parameter
How do I pass as parameter a visibility and then set it? Ex: private void _setVisibility(View.VISIBLE a){ _viewLineStatus.setVisibility(a); }