Posts by utluiz • 72,075 points
957 posts
-
6
votes2
answers129
viewsA: Operation with Java Factorials
Being T one of the terms of the series in question, given in general by: T = SINAL * (X ^ EXPOENTE) -------------- DIVIDOR! And whereas: SINAL is a number that alternates between values 1 or -1,…
-
1
votes1
answer125
viewsA: ERROR starting the java project with Tomcat
Conform already mentioned in comments, the error is yes by trying to load a compiled class with a different version of Java. For example, the WAR classes have been compiled with Java 7 and Tomcat…
-
4
votes1
answer609
viewsA: Loading multiple images through Javascript
The correct is getElementsByTagName: var imagens = document.getElementsByTagName("img"); Alternatively you can use querySelectorAll, which is more flexible and would allow better filtering of the…
-
4
votes1
answer566
viewsA: Create inputs for images dynamically and move to Servlet without redirecting the page?
Manual implementation You can add multiple upload buttons on the page by adding elements in one div container. Example: $('#container').append('<input type="file" />'); Then at the time of…
-
5
votes2
answers637
viewsA: Convert Html to Canvas
Canvas does not render HTML, only "images". There are some libraries that may try to convert HTML into images, such as html2canvas. However, you can create a Web Component to have "a page in a tag".…
-
5
votes2
answers168
viewsA: What makes an object eligible to be allocated in the stack?
What are the criteria that make an object eligible to be allocated in the stack and not in the heap? Fit into the allocated space. Note that you can set the size of stack with the parameter -Xss. If…
-
0
votes1
answer40
viewsA: Problems with Ws
Jersey does not support automatic serialization of any kind, in this case ArrayList. A Provider is a special type of class that checks the type of return of the method and the format it is producing…
-
2
votes1
answer516
viewsA: Is it possible to load classes dynamically and use them as a type?
Is not possible. Java is a strong type language. This means that the compiler checks whether the methods and attributes you are accessing exist and are compatible with code usage. The only way to do…
-
8
votes2
answers159
viewsA: Better applicability to make an interface functional
As described in documentation, this annotation serves primarily to state your intention to use it as a functional interface. One of the aspects involves leaving this intention explicit and…
-
2
votes2
answers336
viewsA: Contact form 7 in custom post
To Official FAQ has an entry for this problem. The most frequent cause is some plugin or theme causing incompatibilities, for example when the plugin or theme adds different versions of libraries…
-
3
votes1
answer87
viewsA: Authentication in different databases
My approach is correct? Probably not. Security is not just about comparing passwords in the database (authentication). Such an important point involves the level of access of users (authorization),…
-
2
votes1
answer1818
viewsA: How to pick up only links in a source code?
Using the Jsoup library this is quite simple. The very documentation brings the following example: File input = new File("/tmp/input.html"); Document doc = Jsoup.parse(input, "UTF-8",…
-
18
votes4
answers4172
views -
2
votes3
answers159
viewsA: Applying Interface in Controllers
What you’re saying is, pray you want it: public interface IController<E> { void adicionar(E Element); ... } And now this: public interface IController<E> { E adicionar(E Element); ... }…
-
4
votes4
answers569
viewsA: In Object Orientation, does an inheritance violate encapsulation?
We have to look at this discussion from the point of view of what it is encapsulation: A mechanism to restrict access to class items Encapsulation allows you to create an isolated implementation, so…
-
2
votes1
answer113
views -
0
votes1
answer143
viewsA: I’m having trouble connecting SQL with java
NPE means that some variable is not properly initialized. If you had told which line was the problem it would be easier to find out which invalid reference. If the error is really in the above code…
-
2
votes3
answers550
viewsA: Print the Thread ID
You are trying to access the ID in the array and not in the elements. To access the Ids individually you need to traverse the thread array in the second loop as you did in the first. Example:…
-
3
votes2
answers232
viewsA: Power method and exception treatment
Basic implementation Create a class that has only one power method, which takes 2 numbers and calculates the number 1 to the number 2. It is unclear whether you can use ready-made API or whether it…
-
3
votes2
answers140
viewsA: Calling the Java compiler from a Java class
Use the method ToolProvider#getSystemJavaCompiler to obtain an instance of JavaCompiler. Then you can compile classes using the template below (extracted from the documentation): File[] fontes = ...…
-
3
votes1
answer987
viewsA: Notifications with Spring
Explaining in detail, step-by-step, how to develop the system is something out of scope. But basically you can use Spring Boot to facilitate the hard work. The architecture is simple: The server…
-
0
votes1
answer200
viewsA: Redirect to another URL based on the URL you entered
One way to show another page within the same domain in a frame is to dynamically change the address via Javascript: First, set a blank address and a id in the frame: <frame id="webmail" src="#"…
-
3
votes2
answers590
viewsA: How does creating an Array work?
Arrays are objects To documentation about Arrays says that they are objects that contain a fixed number of values of a certain type. This can be proved by the following code: String[] array = new…
-
8
votes3
answers404
viewsA: How do you test something "unstoppable"?
That’s a good question. I’m going to focus on the "sub-questions" (in different order) to come up with an answer... And if the class does things like network connection, reading and writing files…
-
9
votes2
answers7033
viewsA: What is to bind?
Bind or Binding are terms used in different applications, but in general refer to how Java or any language links certain things. Data Binding Define how data in different formats are mapped to and…
-
5
votes1
answer127
viewsA: Ball movement in Volleyball game is too fast
First of all, there are some concept problems in the method. If you want to perform a parable movement, you have to think in terms of a quadratic function of the kind y = ax² + bx + c. The fact that…
-
9
votes2
answers692
viewsA: What is the purpose of the super command when used in the parameter declaration of a method?
That’s part of the concept of countervariance applied to the concept of Java generics. Covariance in generics Just to put it in context, covariance occurs when we use extends and allow a more…
-
4
votes2
answers3331
viewsA: Check whether the attributes of an object are null in a less manual way
The most appropriate way to ensure that the attributes of an object are properly defined is to force their initialization during the initialization of the object. It is good practice that all…
-
4
votes4
answers2291
viewsA: How to do a search inside this vector of objects?
Multiple ways to search an array... Using regular expression The following routine returns contacts whose name contains the value passed by parameter: public Contato[] pesquisarNomesParecidos(String…
-
1
votes1
answer521
viewsA: getOutputStream() error has already been called for this Response
It is part of the Java API that you can only recover a single output object from the sponse, either through the method getOutputStream or the method getWriter. If the code in question is within a…
-
6
votes2
answers1863
viewsA: What is the purpose of the default when used in the signature of a method?
The purpose of a method default is to provide a standard implementation for an interface method in case classes that implement the interface do not implement the method. Remember that an interface…
-
2
votes1
answer48
viewsA: Profile network java (jdbc)
There are some commercial tools that can do this, but I’ve never used them. Basically you must measure, somehow, the time elapsed in the call of the method executeQuery and related methods. What is…
-
6
votes4
answers11902
viewsA: How to validate a standard EAN 13 barcode?
I found interesting how the other answer by Dener Carvalho explains in detail the resolution of the problem. Problems However, the implementation that is provided is far from ideal. Some reasons:…
-
1
votes2
answers397
viewsA: Rename large mass of files
Using regular expressions would give a little more flexibility. See an example: public class WordUpperCaseExample { public static final Locale pt_BR = new Locale("pt","BR"); public static void…
-
2
votes2
answers294
viewsA: Java error inserting picture into spreadsheet. Apache Poi
According to information from documentation versions of its dependencies appear to be incompatible. It says the following: ooxml-schemas-1.3. jar for POI 3.14 or later, ooxml-schemas-1.1. jar for…
-
5
votes1
answer665
viewsA: Messagedigest and hash class with MD5 in java
The class MessageDigest provides functionalities of hashing. The term Digest refers to a type of "summary" of the data, that is, nothing more than a hash makes, generating a relatively small byte…
-
4
votes5
answers12645
viewsA: How to create a vector without determining its size in Java?
It is not possible to create a vector with variable size. What you can do is dynamically vary the size of the vector that is created, as in C99. Creating array varying in size Example: Test[]…
-
1
votes1
answer36
viewsA: Deleting a Watcher’s subfolder ends the loop
According to the comments, you are monitoring the subdirectories recursively. However, the API of Watcherservice standard supports monitoring one directory at a time, and to monitor multiple…
-
3
votes1
answer616
viewsA: How to get the name of the remote user connected to the java server?
It is not possible, in any technology, to directly read the user name of a remote computer. Obvious security issue. Even if it was, it wouldn’t be reliable. However, if what you want is to…
-
9
votes2
answers3170
viewsA: Is it possible to store an Arraylist in a Java database?
The question is posed inappropriately. You can understand that you have a list of values and want to save this in a Mysql database, but these are two completely different worlds and you need to…
-
28
votes3
answers6210
viewsA: What is the purpose of the symbol :: in Java?
The operator :: was added to Java 8 and is part of expressions that reference methods (Method Reference Expressions). References to methods (Method References) to complement the Ambids. A lambda is…
-
40
votes3
answers17504
viewsA: What is the purpose of Transient and Volatile in Java?
They are not access modifiers, but modify how the Java Virtual Machine handles attributes at runtime. Transient attributes A transient attribute means that it will not be serialized or deserialized…
-
1
votes1
answer721
viewsA: How to generate a matrix of 3 columns where for each column there are 3 different possibilities?
This problem is known as permutation with repetition. I searched other sources and in Portuguese to explain the problem better, but unfortunately only found garbage (sorry the term, but I’m…
-
7
votes4
answers3043
viewsA: What are temporary tables for?
What are the temporary tables for? They are usually used to temporarily process or store data with variable size in memory, when simple variables are not sufficient. What use can these so-called…
-
7
votes2
answers515
viewsA: Are Ltenatives for complex conditions in a lambda expression?
Yes, but it depends on the context. In the case of filters, the type of expression required is of the Predicate<T>. Predicates are nothing more than a function that returns a boolean value.…
-
4
votes5
answers5903
viewsA: Capture filename in directory
Whenever possible prefer the new Java 8 API that uses the class Path. For example, you can list the files in a directory like this: Files.walk(Paths.get("/tmp"), 1, FileVisitOption.FOLLOW_LINKS)…
-
9
votes1
answer808
viewsA: What is Event-Dispatching Thread (EDT) in graphical interfaces?
TL;DR It is the only thread that can directly manipulate the graphical interface to avoid competition problems. It sits in a loop waiting for events coming from the screen (clicks, keys, etc.) or…
-
1
votes2
answers127
viewsA: Class that cannot be serialized
Class name be logged in as Bean.ContatoBean suggests that she is an inner class (Inner class), that is to say, ContatoBean is stated within Bean. I also assume that the outer class has an attribute…
-
3
votes2
answers71
viewsA: Socket- does not receive the message in full
As @epx has already mentioned, data is transmitted over the network in blocks, so you need a loop to recompose the data blocks until the expected total amount of bytes is received. An advantage of…
-
1
votes3
answers754
viewsA: Access-Control-Allow_origin error not allowed
Headers need to be uploaded before any content. Switch to: <?php header("Access-Control-Allow-Origin: *"); ?> <!DOCTYPE html> <html> <head> ... And ensures that the file is…