I’m trying to write a method in Java that will be able to add a custom Key object to an array, or change an already existing key in the array if there is one. However, I can’t seem to get it to work. The types that keys will use are primarily be String and Integer, but my universal approach doesn&…
Tag: java
What happens between setVisible() and a component being painted?
I have a JScrollPane that contains a JPanel which then contains some custom components which are an extension of JPanel (they are all the same type). This JScrollPane is set invisible before the containing JFrame is shown. When the user selects a JCheckBox I use setVisible() to show the scroll pane. The first…
JavaScript, Java, Php, or C++ cipher encryption – reworking algorithm
I am trying to implement a loop that encrypts a string to the given shift amount of int shift. The code below works great, however I’d like to change the code so that it encrypts in a descending order instead of ascending. Any clues as to what to change in the algorithm? With a shift of 3, the above cod…
Moving files from one directory to another with Java NIO
I am using the NIO libraries but I am getting a strange error when I try to move files from one directory to another. Iterate over elements that start with “2014” and move them in the new directory (newDir, which is also called 2014) I get the java.nio.file.FileAlreadyExistsException because my fo…
How to convert certificate from PEM to JKS?
I have to convert a certificate in PEM format into an Java key store. To use this one with tomcat at a windows server I’ve got those files: cert_request.csr cert_public_key.pem cert_private_key.pem cert.txt I tryed to combine the pem files (by combining the two files were chain together) and converted t…
Java VisualVM does not show/list my tomcat java process
I am using jdk64 and my java version is 1.6.0_24. I am running both (Tomcat java process and VisualVM) processes as Administrator on Windows Server 2008. Tomcat is running with -Xmx7196m, where as jvisualvm is running with -Xms24m and -Xmx256m. Could this be the cause? Answer You need to add the JMX parameter…
How to get the time of the day in milliseconds?
I want to get the time of a day in milliseconds, I do not this day to have any specific date, just a time. I made something, thought it worked, but then went debugging and concluded that it doesn’t work how I want it to. I want to use this to check if the current time is between both my
Java Graphics Invert Color Composite
Basically what I want to do is make a cursor for a JComponent that’s pixels appear as the inverse of the color they are over. For example, take your mouse and hover it over the letters in the url for this page. If you look closely, the pixels of the cursor that are over black pixels of a letter turn
Iterator vs for
I was asked in an interview what is the advantage of using iterator over for loop or what is the advantage of using for loop over iterator? Can any body please answer this? Answer First of all, there are 2 kinds of for loops, which behave very differently. One uses indices: This kind of loop isn’t alway…
Web Service Authentication to Online Federated Dynamics CRM 2013 from Java
I am working on a Java program to integrate via web services with a Microsoft Dynamics CRM 2013 online version. Authentication is federated with a local IDP, not through Windows Live. I am having problems finding documentation on how to complete this. All of the non-.NET environment documentation I have seen …