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
votes1
answer233
viewsPassing multiple parameters as an Array
I have a method that takes an unknown amount of parameters like an Array, thus: public void enviarCampos(String funcao, String... campos) { // Ação do método } To call this method do:…
-
4
votes1
answer176
viewsmysql driver is not found when the application is rotated from a jar
I have developed an employee registration system. In this system the data persistence is done in a mysql database. When running the program by the package the system works normally, but when…
-
4
votes1
answer102
viewsTreat a word with dots
I have a method that takes a text as a parameter and makes a .split in the text separating the words by " ". For each word in the text I make a check to see if the word is equal to the item in my…
-
4
votes2
answers1673
viewsHow to resolve this 'java.lang.Illegalargumentexception: Unknown Entity' when running this simple application?
I am new to the world of Hibernate and when I run this application, I get the following exception: java.lang.IllegalArgumentException: Unknown entity: com.nataniel.api.domain.User at…
-
4
votes1
answer161
viewsIs it possible to copy files without using a stream buffer?
In my application, I have a class that periodically performs a backup of a file, considerably small (less than 1MB), but I am doing some tests and after reading this answer, it seems to me that it…
-
4
votes1
answer160
viewsUsing Callable in java runs code sequentially
I am making a server in java wanted to perform certain tasks in parallel. I have a list of a certain type I want 20 threads to deal with elements of the list. for( Item item : result ) {…
-
4
votes1
answer214
viewsWhat is the difference between using the Enum Standardcopyoption constants?
I am implementing file copy and decided to use the class Files, and one of the signatures of the method copy() is to receive 2 parameters of type Path and a third of the kind CopyOption and this is…
-
4
votes0
answers31
viewsWhat is a TLAB and what is it for?
I recently used Java Mission Control (JMC) to track a memory Leak. In doing so I realized that JMC reports memory allocations inside and outside of Thread Local Allocation Buffers (TLAB). In a quick…
-
4
votes1
answer669
viewsDecorating a Jtextfield with an icone
My question is whether it is possible to "decorate" a field, like Jtextfield or Jformattedtextfield, with an icon. An example would be something like this: Following an example, I made the following…
-
4
votes1
answer79
viewsIs it possible to force a method to be extended in Java?
It is possible to "force" a method to be extensible? The statement of the exercise says exactly this: we have to create a class, within it create a method and force this method to be extended. From…
-
4
votes1
answer171
viewsHow to map two equal entities with Hibernate
I have a scenario where I have the entities Pedido and Usuário. The Pedido is composed of some attributes, among them the requester that is mapped as follows: @ManyToOne(fetch = FetchType.EAGER)…
-
4
votes1
answer77
viewsWhy does the Math.toRadians method return an inaccurate value?
I was programming a method in which I needed to convert a value from degrees to radians and I wondered if this conversion no longer existed in Java. Searching the Internet I discovered the method…
-
4
votes2
answers67
viewsHow to reverse series of denied conditions without affecting logic?
Could someone explain to me why this happens? My apk only works right if I put denial and do something: public class Main2Activity extends AppCompatActivity { private EditText nome, teste, cpf;…
-
4
votes1
answer5011
viewsError Connection Database; "relation does not exist"
I am having Problem to Save Data from a Screen to my database I am getting the following error: "org.postgresql.util.PSQL.Exception: ERROR: column "name" of relation "product registration" does not…
-
4
votes1
answer356
viewsDatabase Locked Sqlite/Java error
I have the following problem: in an Insert that I am trying to accomplish, I don’t know if it is an error in the database or something in the java programming, but every time I try to perform an…
-
4
votes1
answer339
viewsAlert Dialog personalized with GIF image
I would like to know how to create a Alert Dialog customized where you had an Imageview containing a GIF. On my Main. imgAndroid = (Button) findViewByid (R.id.imagandroid);…
-
4
votes1
answer315
viewsDoubt when taking Map’s value
Hello. When I print out the values and key of the Map, it comes from bottom to top. I wonder how I do to pick up from top to bottom. import java.util.HashMap; import java.util.Map; import…
-
4
votes3
answers851
viewsHow to create a stopwatch in Javafx using Scene Builder?
Guys, I’ve been a few months with some stranded projects, because I can’t get a label keep up to date. I can make a stopwatch, but when it comes to the interface created by Scene Builder, it crashes…
-
4
votes1
answer3193
viewsJava SOAP webservice authentication engine
I am building a Java webservice (wsdl) that will be consumed via SOAP. I need to implement a form of authentication in each method of the webservice so that each request is tested if the source is…
-
4
votes2
answers1474
viewsIs it possible to do an INSERT and UPDATE in the same query in java?
I wonder if it is possible to make one INSERT and a UPDATE in the same query, that is, in the same operation. I’m using the following to do both operations. public Connection conn = null; ... conn =…
-
4
votes1
answer5435
viewsHow to fix the error: HTTP Status 500 - Servlet Execution threw an Exception?
Language: Java Server: Apache Tomcat. Ambient: Eclipse. I am following the Caelum Workbook of the course FJ21 - Web Development with Java. I created a form but at the time of recording it presents…
-
4
votes2
answers5541
viewsExpected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 Com Webservice JAX-RS e Android Retrofit
I’m studying Webservice and consumption on Android with Retrofit2. I’ve done tests with public Apis like Viacep and FIPE and I can use the retrofit quietly, very easy but when I set up my own…
-
4
votes2
answers498
viewsHow can I easily make application location permission?
I found this tutorial https://inthecheesefactory.com/blog/things-you-need-to-know-about-android-m-permission-developer-edition/en but I didn’t understand anything. I looked at this tutorial: //…
-
4
votes1
answer93
viewsHow to capture only the first part of a text that fits in regex?
<END>Av. Dr. Walter Belian, nº 2.230, Distrito Industrial, João Pessoa-PB, com CNPJ nº 07.526.557/0013-43 e Inscrição Estadual nº 16.218.7157; (NR) II - Sergipe, localizada na Rodovia BR-101,…
-
4
votes1
answer2410
viewsHow to catch a JSON from a URL?
I continue studying Androidstudio and the ball of turn eh catch data by URL, in json format, For that reason created an example page: (http://exemplo.minha.info/nav/2.html), with the following…
-
4
votes2
answers106
viewsWhat method to make you download all the media volume on Android?
My application needs the user to be able to choose at its beginning whether they want to hear the sounds of the app or not, because it is an app to be used in the classroom and in this environment…
-
4
votes1
answer620
viewsTraversing Dates using Calendar
I’m making a report on java, I spend a period specified by the user. In my DAO I’m doing the treatment. Here I take the last date. String data1 = DateUtil.toString(dto.getDataInicio(), "MM/yyyy");…
-
4
votes3
answers180
viewsHow to use repeated methods?
I have some methods that I use in various points of the applications and I end up having to copy in each class. For example: String getStringOrEmpty(EditText editText) { String mString =…
-
4
votes2
answers301
viewsContest Question: Java code about over-writing methods
I took a competition and dropped the following question: Check the alternative corresponding to the result of the execution of the main method of the Java program shown below: public class A {…
javaasked 7 years, 9 months ago Denis Caixeta 3,427 -
4
votes1
answer771
viewsPicasso cache of images
I’m testing the library Picasso in the android in two situations: 1 - When loading an image, in a url publish (without sending headers authentication), the image is loaded into the ImageView, and…
-
4
votes1
answer105
viewsLock optimistic; why not fire exception?
I tried to simulate an optimistic Lock situation where one tries to update the same record twice, but the excesses are not triggered. I find it interesting is that even after changing the value of…
-
4
votes1
answer258
viewsAssign a function to Jcombobox
I am with the following doubt, I have a combobox, and I want that when you click on one of the combo options, it does something. I wanted to know how I put a variable or method "linked" to combo…
-
4
votes1
answer4925
viewsTO_DATE(SYSDATE, 'YYYY-MM-DD') works sometimes
I have the following problem: I use the JDBC to connect with Oracle. And I call rs.getTimestamp(index) to pick up a date field. When I run the function TO_DATE(SYSDATE, 'YYYY-MM-DD') the…
-
4
votes1
answer560
viewsFlashing buttons with Thread
I’m having a problem trying to make the buttons blink. Using the Thread.sleep(), by clicking the button, Thread.sleep() ignores what comes before it, executes the sleep and performs only what comes…
-
4
votes1
answer1892
viewsHow to call one function inside another in Java for Android?
Every letter the user types in EditText, invokes the function TextWatcher that leads to a Text-to-speech. So if it writes 'c', the app returns a line saying 'c'. if it then enters 'a', returns 'a'.…
-
4
votes1
answer405
viewsTesting Factory Hibernate
Is giving null Exception on line HibernateUtil.getFactory().openSession(); in the main method. Follow how are the configuration and test files: <?xml version='1.0' encoding='utf-8'?>…
-
4
votes3
answers2718
viewsWhat is the correct way to pass the pagination data in Sponse REST?
In more robust applications, where a table can have millions of records, it is important to implement paging in a REST API. I have seen in some projects two ways to return pagination information…
-
4
votes1
answer437
viewsWhy does the Jframe size exceed the size of your Contentpane, even though it has a defined size?
I noticed a strange behavior between containers in the swing. To illustrate the test, I created a JFrame and a JPanel, and defined the panel as contentPane of JFrame. Set the preferred and maximum…
-
4
votes1
answer253
viewsDoes AJAX requests work on Webview?
I got the following WebView: WebView myWebView = (WebView) findViewById(R.id.webview); myWebView.getSettings().setJavaScriptEnabled(true); myWebView.getSettings().setBuiltInZoomControls(true);…
-
4
votes1
answer270
viewsModifications in Jfreechart
I would like to know, how can I change the colors of the "slices" of the graph and the font where the content and percentage are written. Is it possible? at least the colors. package grafico; import…
-
4
votes3
answers2418
viewsHow to make a rectangle of asterisks using for?
To solve this exercise: Write a program that prints a rectangle of n x m asterisks, in the which values of n and m are provided by the user. For example, for values of n = 5 and m = 7, the expected…
-
4
votes1
answer1215
viewsHow to change the background of a button when clicked?
I need to change the background of a button when clicked. Here’s the code I tried: private Button btn; private int colorFlag = 0; @Override protected void onCreate(Bundle savedInstanceState) {…
-
4
votes1
answer152
viewsBean and Annotations with Generics, how to do?
I am in a project with Spring 4 configuring the Redis and a construction like this has emerged: @Configuration @ComponentScan({"com.empresa.sistema.web.util"}) public class RedisConfig { @Bean…
-
4
votes2
answers279
viewsIs there a difference in how polymorphism is applied in Java and C# ?
I’m studying the concepts of POO and generated me a doubt. In Java I believe I can access all methods and attributes declared as public in a subclass even when using a superclass type variable to…
-
4
votes1
answer937
viewsRunning cmd commands or scripts from java does not work
I’m having trouble running some commands through java. Whether I run them directly from Netbeans or run the project directly from my machine works perfectly any of the following commands: String…
-
4
votes1
answer1320
viewsHow to change the color of the border?
How I could change the color of the border created by Borderfactory? import java.awt.Dimension; import java.awt.GridBagLayout; import javax.swing.BorderFactory; import javax.swing.JComponent; import…
-
4
votes2
answers1548
viewsHow does Asynctask actually work?
Still, sometimes I get a little confused by the AsyncTask. See an example below: private class MyAsyncTask extends AsyncTask<String, Void, String> { @Override protected String…
-
4
votes1
answer1305
viewsCan I get the list index inside for-each in java?
When we created the for traditional we do this way: for(int i = 0; i<strs.lenght; i++){ Log.wtf(TAG, "Jon Snow is "+strs[i]); } Now I have this foreach: for(String str: strs){ Log.wtf(TAG, "Jon…
-
4
votes1
answer699
viewsWhy use Drivermanager for connection to bank?
I am connecting to the Sqlite database with the following code: public SQLiteConnection conn() throws SQLException{ String path = System.getProperty("user.dir"); try { return new…
-
4
votes2
answers269
viewsUnderstand error message
I’m not getting this error message. Someone understands and can help me? Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Arrays.java:3210) at…