Evan Caballero

Ranch Hand
+ Follow
since Dec 10, 2009
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Evan Caballero

Hi there, I'm proud to present you my first application : aTrip !

It is a trip dashboard application, like you can find in cars for example. It displays your current speed (digital), and other information about your current trip : duration, average speed, max speed, and distance.

In landscape mode, it only displays the speed, with a larger font

There are a few preferences for the application :
unit -> km/h or mph (knots is for future version)
background color
font color
keep screen on (prevents screen to shutdown while application is running

I hope this application will be your best friend while driving your car Don't forget to evaluate it and to post comments on the market !

14 years ago
Try to "uncheck" the "Resolve Workspace Artifacts" checkbox in the maven run configuration under eclipse (assuming that you use the maven eclipse plugin)
14 years ago
there is no alternative. you have to you javascript
If you don't want to use env variables, symbolic links under unix can do the trick.
14 years ago
you can use an environment variable for that.

Imagine that your property files are in the /var/myapp/cfg directory on your system. Instead of harcoding this path in your app, declare an env variable like : MYAPP_CFG_PATH=/var/myapp/cfg
To retrieve this value, use System.getEnv("MYAPP_CFG_PATH");

Then, if you have different configuration files for different environments (dev, prod etc ...) you can use a trick like this one :

declare an env variable for each environment
-> MYAPP_PROD_CFG_PATH = /var/myapp/prod/cfg
-> MYAPP_DEV_CFG_PATH = /var/myapp/dev/cfg

and, before you deploy your application, just switch from one to the other like this :


This technique is great because it also works on windows. Instead of /var/myapp/prod, you can put D:\var\myapp\prod in the env variable.

Remember, on windows, env variable values are accessible using %MYAPP_PROD_CFG_PATH% instead of $MYAPP_PROD_CFG_PATH on unix. But from the java side, it's the same way : System.getEnv("MYAPP_CFG_PATH");

NB :
this also works for the JAVA_HOME variable, if you use your server to deploy apps with JDK 1.5 and JDK 1.6
declare env like these :

With all these stuffs, the only thing that is hardcoded in your application, is the name of the env variable.

I hope this will help you ;)
14 years ago
an abstract class can contains attributes that will be inherited by all its sub classes for example. So, declaring a constructor enables you to initialise all these attributes in the super class, and not for each constructors of your sub classes.

14 years ago
In fact, when you do i.asList(), it returns a list of int[] (List<int[]>) with one element :/

like [{ 1, 2, 3, 4, 5, 6, 7, 8, 9 }]

so, there is no element at index 4 ; there is only an element at index 0, which is your original int[].

the asList method considers that you want to build a list from one int[], which IS an object. It is like if you were doing Arrays.asList(i1, i2, i3, i4), where i1 i2 i3 and i4 are int[] objects.
14 years ago
I made a few changes to your code, but I'm not sure this is what you want :

14 years ago
And so, what is the final answer to the original question ?
14 years ago
here it is :

I think that when the JVM autoboxes int to Integer, the Integer.equals() method is ignored or something like that.
14 years ago
to use a LinkedList as a LIFO queue, call addFirst and removeFirst methods only ;)
14 years ago
the LinkedList implementation of Collection has methods addFirst, addLast, removeFirst and removeLast. I think you can use it to implement a LIFO queue.
14 years ago
if you try to load a file that is actually in the classpath of your application, for example in the classes directory, you can use

or, if you don't want to have a headache with paths under different OSs, you can get the absolute path, plateform dependent, this way : new File("/some/path").getAbsolutePath().

3rd trick, the static attribute File.pathSeparator varies if you are under unix, windows etc ... Under unix, it is initialized as "/" at the start of the JVM, as "\" under windows.

Hope this should help you ;)
14 years ago
perhaps there is a mistakes here : fis = new FileInputStream(args[0]);

If you do not pass any arguments to your program, the args array will be of length 0, so there won't be any element à index 0.
14 years ago
perhaps you could use a -Djava.something parameter while lauching your application.
14 years ago