I need to compile my source code to be compatible with JRE 1.6. However, when I attempt to set the compiler attribute of the javac task to be javac1.6, Ant will still compile my code with javac1.7. I have also tried setting the compiler version to be “modern” and that did not work. My JAVA_HOME is…
Tag: java
Fastest way to scan ports with Java
I made a very simple port scanner, but it runs too slow, so I’m looking for a way to make it scan faster. Here is my code: This code tests if a specific port is open on a specific ip. For timeout I used a minimum value of 200 because when I go lower it doesn’t have enough time to
Cannot create JDBC driver of class ‘ ‘ for connect URL ‘null’ : I do not understand this exception
Why does it say null URL and gives a empty ‘ ‘ class in the exception when I have provided the database URL? I am trying to connect to a derby database via a servlet while using Tomcat. When the servlet gets run, I get the following exceptions: Servlet : What exception is this? Why do I get this e…
Spring AOP Advice Called Twice
For some reason, my Spring AOP advices are being called twice. I checked: Spring AOP advice is called twice but I am not using the Component annotation, and am declaring the aspect bean once and annotating it with @Aspect and that’s it. Somewhat belatedly I realized that one of my classes was not implem…
Java applets – is it a wrong choice today?
I have some non-trivial computational code that need to be applied on data already downloaded into the browser DOM and captured from user interactions. I do not wish to expose this code. I am wondering if: Write a webservice and communicate with the browser over websocket or HTTP. The trade-off is speed of in…
Assigning values of an array in a for loop java
Im still starting out in java – and any guidance would be great on this. I’m basically hoping to create an array, then assign values to that array in a for loop. The code I have at the moment is: All i wanna do is make an array with each entry the number of the iteration (using this method) I
How to implement enum with generics?
I have a generic interface like this: This interface has limited instances, hence it would be best to implement them as enum values. The problem is those instances have different type of values, so I tried the following approach but it does not compile: Any idea about this? Answer You can’t. Java doesn&…
How to recursively scan directories in Android
How can I recursively scan directories in Android and display file name(s)? I’m trying to scan, but it’s slow (force close or wait). I’m using the FileWalker class given in a separate answer to this question. Answer You should almost always access the file system only from a non-UI thread. O…
SharedPreferences being reset after force close
I have been able to successfully implement Shared Preferences into my application but I have ran into a problem with the data being reset/deleted if I kill the application through a task manager. I am using a static method for saving, that way I only need the method once and can call it everywhere within my a…
How to use for checking multiple Roles?
I want to display some content conditionally based on Roles using Spring Security JSP taglibs. But in Spring Security 3.1.x is checking for only one role. I can use but ifAllGranted is deprecated. Any help? Answer There is a special security expression in spring security: hasAnyRole(list of roles) – tru…