Posts by Victor Stafusa • 63,338 points
1,321 posts
-
1
votes3
answers697
viewsA: Noclassdeffounderror
More details on this link: https://stackoverflow.com/questions/183292/classpath-including-jar-within-a-jar Basically, there is no official way to load the classes of a JAR that is inside another…
javaanswered Victor Stafusa 63,338 -
0
votes3
answers697
viewsA: Noclassdeffounderror
Add to your manifest.mf the following line: Class-Path: libs/JNativeHook.jar Perhaps the following can also work to load one JAR into the other, depending on how it is organized internally:…
javaanswered Victor Stafusa 63,338 -
0
votes3
answers697
viewsA: Noclassdeffounderror
Instead of: java -jar AutoClick.jar Try: java -cp ./libs/JNativeHook.jar -jar AutoClick.jar…
javaanswered Victor Stafusa 63,338 -
0
votes1
answer1678
viewsA: CPF validation on Android - Arraylist error
As already said in the comments, is missing the class Separador. Let’s design this class: public class Separador { private final Integer posicao; private final String caracter; public…
androidanswered Victor Stafusa 63,338 -
2
votes1
answer5336
viewsA: Detecting colors or geometric shapes of an image
See if this fits you. Made with java 8. Comments explaining how it works are in the code: import java.awt.image.BufferedImage; import java.io.IOException; import java.net.MalformedURLException;…
-
5
votes2
answers120
viewsA: Why do certain services still depend on the Java plugin?
The Java plugin is nothing more than something that is used to embed Java applets on web pages, similar to what is done with Flash. Its purpose is only to make Java applications available in…
-
1
votes1
answer133
viewsA: Retrieving data from an object
I think it’s worth unifying your classes Alunos and its class BuscarAluno, because both seem to me to represent the same concept, which is your student database, even if that database is just an…
-
5
votes5
answers1721
viewsA: Is it possible to change the type of the variable in Java?
YES But it will be very laborious. This is a job that involves a lot of black magic and evil sorcery. Some dark entities will have to be summoned to the world of the living. What you need to do is…
-
2
votes3
answers4417
viewsA: Java 8 (Stream) - Grouped sum
I did, but it took a lot of work: import java.math.BigDecimal; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; /** * @author…
-
4
votes1
answer514
viewsA: How to know if it is mouse click or robot?
I’m not entirely sure, but the class java.awt.Robot must enter click events in the operating system queue. So much so that you can use it to click on other programs, drag-and-drop on the desktop or…
javaanswered Victor Stafusa 63,338 -
4
votes2
answers551
viewsA: I’m in trouble when I invoke a method - JAVA
Your problem seems to be this line in your method menuPrincipal() class Menu: dao.mostrarClientes(); Especially considering this is inside a bond while (true). However, do you know what a DAO is…
javaanswered Victor Stafusa 63,338 -
2
votes1
answer1876
viewsA: Returning database id in a global variable. How to fix?
Respect naming conventions. Rename the following variables and methods: Center in class TelaPrincipal -> center Button in class TelaPrincipal -> button SQL as a parameter of the methods of DAO…
-
12
votes2
answers1341
viewsA: Format echo time number with 'k', 'kk', and so on
Here is your function: function reduz_numero($n) { if ($n < 0) return "-" . reduz_numero(-$n); $k = ""; while (round($n) >= 1000) { $k = $k . "k"; $n = $n / 1000; } return round($n) . $k; }…
phpanswered Victor Stafusa 63,338 -
0
votes1
answer285
viewsA: Intersection and Subtraction Groupings
As the name already says, the intersection will intersect two regular expressions. That is, the intersection of n regular expressions is a regular expression that will give match if all the n…
-
5
votes1
answer122
viewsA: Problem with Struct
What you want is a student with five ages and five averages or five students each with an age and an average? If you want a student with five ages and five averages: So the problem is on this line:…
-
7
votes1
answer805
viewsA: Doubt with the function compareTo
The method compareTo class String is used to sort the Strings alphabetically*, not by size. This way we have to "araraaaaaa" comes before "asa", and therefore the compareTo gives -1, because when…
javaanswered Victor Stafusa 63,338 -
1
votes1
answer310
viewsA: Doubt with javascript college work using DOM
First you have to read the product and quantity values: var produto = document.getElementById("produto").value; var quantidade = document.getElementById("quantidade").value; You will need to have…
-
1
votes2
answers71
viewsA: How to get multiple Jsonobject with the same key?
I don’t know exactly where you got the classes from JSONArray and JSONObject, since there are many different projects independently made by many different people who have classes with these names.…
-
0
votes3
answers3183
viewsA: How to return the instance of a class in Java
Can anyone tell me how to return an instance of a java class??? Yeah, just do that: return instancia; I’ll try to explain it better, I have a Server class, I urge the class to become an object I…
javaanswered Victor Stafusa 63,338 -
3
votes3
answers3183
viewsA: How to return the instance of a class in Java
Use the Singleton project pattern. Make your builder private. Store an instance of your class in a private static field. Always return the same instance (the one in the private static field) in the…
javaanswered Victor Stafusa 63,338 -
10
votes8
answers5853
viewsA: Recognize word repeats in String
I decided to reimplementate from scratch. The reasons: Do not depend on custom list implementations; Not depend on Strings with special and arbitrary values; Don’t need any numbers hardcoded or…
-
16
votes2
answers1520
viewsA: What are the benefits of using HTTPS?
Where SSL makes a website safer? Encryption. In normal HTTP, data is sent to plaintext within the network packets and someone using a Sniffer, which is a program that captures the packets, you can…
-
9
votes1
answer6781
viewsA: Calculate distance between 2 points in Google maps
I think I got it right. First I fixed the problems with the malformed HTML: Missing </body> and the </html> at the end, which I added. You have an element <table> left that is…
-
6
votes1
answer1832
viewsA: How to Make a Simple Assembly Assembler
What you are asking for is to make a simple compiler, which receives a source code and produces a machine code. Structure of a compiler The compilation process is normally divided into the following…
-
7
votes4
answers2193
viewsA: How do I search a value within a String?
First of all, you don’t seem to know exactly what a String. That’s a String: String THAT’S NOT A String: String[] THAT IS NOT A String: String[][] Okay, so what’s a String[] and a String[][]? A…
-
83
votes1
answer4219
viewsA: What are the advantages of using the right HTTP methods?
Let’s start by looking at our approaches to doing a CRUD on a server and forging some Urls to analyze. The first approach (let’s call it To) is to use the appropriate HTTP verbs: GET…
httpanswered Victor Stafusa 63,338 -
7
votes1
answer161
viewsA: Is it a good idea to map Urls that delete GET entries?
That’s a bad idea GET must be safe, as specified by W3C in RFC 2616 (take a look at chapter 9): 9.1.1 Safe Methods Implementors should be Aware that the software represents the user in their…
-
4
votes2
answers89
viewsA: Desktop widgets in Java
I’m with an idea to create a widgets with support functionality for my company. OK. I wonder if via java I could create something Yes if there is any framework or technology in Java where you can…
javaanswered Victor Stafusa 63,338 -
1
votes3
answers474
viewsA: Fscanf problem using code::Blocks and Opengl
Although your code contains a few #includes of Opengl libraries, it is not doing anything using Opengl. The only library functions it is using are fopen, fscanf, printf and system. There’s a problem…
-
10
votes1
answer1021
viewsA: Java Graphics Drawing Tool
I think maybe you have to draw the graphics in hand. I made a program that does this. Here is the code: import java.awt.Color; import java.awt.FontMetrics; import java.awt.Graphics2D; import…
javaanswered Victor Stafusa 63,338 -
1
votes2
answers2737
viewsA: How to create two different database connections?
You can open two connections with different databases and then insert the read data from one database into the other more or less like this: String urlMySql =…
-
2
votes2
answers193
viewsA: Segmentation fault in C: Adjacency structure representing graph
I think your main problem is here: G = (grafo **) malloc(sizeof(V*sizeof(grafo))); You missed the parentheses! And as a result it will allocate a much smaller amount of memory than it should, which…
-
3
votes1
answer103
viewsA: Nullpointerexception on android in project to download Pdfs
If you had a NullPointerException, you could post the stacktrace, right? In the method run() of your class DownloaderThread, you are not closing the outStream, the inStream and the fileStream within…
-
28
votes6
answers66144
viewsA: Type of the CPF or CNPJ field in the VARCHAR or INT database?
I’ve always advocated using VARCHAR, because they are a string that coincidentally occurs to be a sequence of digits. Unlike a INT where the purpose of being a number is to allow you to perform…
-
3
votes1
answer124
viewsA: Problem with session in Servet
You are putting the attributes in the session, but one is not cleaning the other. When accessing both pages, both "adverbios" and "verbs" attributes will have been set in the session and both will…
-
2
votes1
answer1430
viewsA: How to add element inside an arrayList that is inside another Arraylist that in turn is inside a Hashmap?
You didn’t say what exactly the field is formaTurma. I suppose it’s a Map<Aluno, List<Disciplina>>, correct? Ideally I shouldn’t have to assume this, since you should have informed in…
-
3
votes1
answer179
viewsA: How to use Futuretask class correctly?
First, your question suffers from some problems: Your code has several compilation errors whose correction is not trivial. First, the variables primeiro and ultimo were not declared, and due to the…
-
4
votes2
answers357
viewsA: Base62 coding
Follows the implementation. Implemented in two different languages: PHP and Java. Allows you to specify the alphabet in the constructor. The alphabet size is obtained from the alphabet itself.…
-
3
votes1
answer133
viewsA: Order a LIST based on another LIST
How about you try that? public class OrdenaMenuPorVisibilidade implements Comparator<Menu> { @Override public int compare(Menu o1, Menu o2) { int d =…
javaanswered Victor Stafusa 63,338 -
2
votes2
answers387
viewsA: Problems with if Else in Servlet
You can put different attributes in the request and read them back in JSP: if (/*condicao*/) { request.setAttribute("caminhoTomado", "if"); rd = request.getRequestDispatcher("resposta1.jsp"); } else…
-
1
votes3
answers1408
viewsA: Working with JPA+Hibernate cache
You must have a EntityManager by database interaction. This means: Never compatilhe EntityManagers between different threads. They are not designed to be single-thread. If you reuse threads to…
-
5
votes1
answer57092
viewsA: How to resolve java.lang.Nullpointerexception?
Your error occurs here: if(msg.equals("quit")){ Actually, there are two lines like this. One simple way to solve this is: if("quit".equals(msg)) { And there will be no more NullPointerException.…
-
3
votes2
answers339
viewsA: CAPTCHA in stateless API
Implementing a CAPTCHA service Create a CAPTCHA service with the following operations: Create a CAPTCHA. Returns a created CAPTCHA id and a CAPTCHA image. Answer a CAPTCHA. Receives a CAPTCHA id and…
-
5
votes2
answers1023
viewsA: Database modeling problem
As it stands on the table vendas There is no way to know which team the seller was on when the sale was held, since he can change teams after making the sale. The simplest solution to this (there…
-
2
votes1
answer58
viewsA: Iterate a String array within an object
Try this: for (TableHelper tables : Config.tableList){ for(String col : tables.columns()){ Log.e("COLUMN", col); } } Explanation: The type of return of your method columns is String and not…
-
4
votes2
answers236
viewsA: Regular expressions
I managed to do with this regex: <tr[^>]*>\s*<td[^>]*>[^<]*<\/td>\s*<td[^>]*>[^<]*<\/td>\s*<td[^>]*>\s*(\S*) It is important you capture all the…
-
1
votes2
answers78
viewsA: Unity3d - Problem with the authentication of the Bitrave plugin for connecting to Azure
According to the tutorial: Open Azureui.Cs script and replace the Connection strings with your Own Mobile Service URL & API Key. Translating: Open the Azureui.Cs script and replace the…
-
74
votes5
answers69449
viewsA: How to make a regular expression for mobile phone?
Nowadays all mobile phones in Brazil have nine digits and start with digit 9 and all fixed phones have 8 digits and never start with digit 9. I would personally prefer to format the phone as (xx)…
-
3
votes1
answer1412
viewsA: Search by date range
The first thing that popped out of my eyes was your query: "SELECT Data FROM PCPEDC WHERE DATA BETWEEN '10/09/2010'" + DataIni + "'AND '" + DataFim +"'" So, let’s assume that the initial date is…
-
3
votes3
answers13363
viewsA: How to validate an input?
Try putting Submit only in javascript. This is your HTML: <form id="frm" action="_graphes.php" method="post"> <input type="time" id="time_debut" name="time_debut" step="1" value=''>…