Chris De Vries

Ranch Hand
+ Follow
since Dec 05, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chris De Vries

If you want to use DateFormat's locale specific formats, then I would stick with the defaults. Trying to convert from 2 digit to 4 digit years could potentially be tricky. However, if you are certain that the locale specific short date format will always return either date, month, year or month, date, year then you can put in a date, say January 2 of any year and see which number shows up first, then conditionally use


or


depending on the order of the integers in the test case. If a locale decides to throw you a curve and use year first then you may be in trouble.

Chris
15 years ago
Unfortunately this doesn't really help with web start. Is there a way to pass properties into javaws? It seems like the -userConfig command line options only work on deployment properties.

Chris
15 years ago
You can run a timer thread and call destroy() on the process after some time elapses, however it might be worth figuring out why the test cases hang. this article might be helpful in that regard.

Chris
15 years ago
In response to bugs in window placement on X systems (see Bug 4102292), Sun added the property which if set to true will allow the window manager to handle window placement. This is great, especially for people like me who have their window managers set to allow them to place windows interactively. The problem is that I would like that property to be set to true for every java program I run, including programs I may be running through java web start. Is it possible to set that property globally without specifying it on the command line every time I use java?

Chris
[ April 21, 2005: Message edited by: Chris De Vries ]
15 years ago
You can just put "Math.floor(...)" in your code. java.lang classes are already imported, I just added the full package name so you could look it up easily. Math is a class containing mostly static functions.

Under j2se1.5 or jdk5 or whatever they call it now, you can do a static import. So you just need to add



and then you can use "floor()" in your code without the class name.

Chris
15 years ago
There are 2.54 centimeters in an inch and 12 inches in a foot. You can try something like:



The key of course is java.lang.Math.floor.

In the future I suggest not using subject lines like "Urgent Help Please Please Please!" People are much less likely to reply because you give no indication what your problem is. Something like, "Converting between centimeters and inches and feet" might be more helpful.

Chris
15 years ago
I have written a couple of shell scripts to run command line java programs from linux. One of the benefits I've found is that I can pass additional arguments to the jvm and use the script to pass environment variables to the jvm as system properties. Here's an example script I wrote:



This illustrates both features I described earlier. I have set the maximum heap size to 256 megabytes, and the script checks for the existance of the environment variable MOLDATA which it passes to the property devries.radxfer.moldata if it exists. the "$@" means insert the script's command line arguments here.

To create an rc script I would take a look at your system's init.d scripts and use a similar format. Debian provides /etc/init.d/skeleton as an example init.d script which uses their start-stop-daemon program to start and stop your daemon.

Good luck.

Chris
[ April 19, 2005: Message edited by: Chris De Vries ]
15 years ago
Hmm... It may be that you don't need HttpClient after all. As I was looking for Base64 encoding, I came across java.net.Authenticator.
It looks like you may be able to create a proxy password authenticator and use it as the default authenticator for the proxy. This code snippet might work:

I have not tried that code, but something like it might work.
Chris
You can generate each number in the sequence by itself, and then output the sequence in any format you want. For example:

Formatting the individual digits is easy, but the four digit sequence might be less that 1000, so you need to ensure a minimum of four digits. Use java.text.NumberFormat for that:

I hope this is helpful.
Chris
16 years ago
Hmm... Well at least it's partly solved. I'm not sure why cookies would be a problem though. I must admit I have never tried using an authenticating proxy server with a java client, so I have not run into this problem.
You may want to ask this question on the Jakarta Commons user email list or developer email list. The mailing list archives can also be searched, though a quick search I did, didn't reveal exactly this problem. I'm sure they would be happy to receive your input and fix it if it turns out to be a bug.
Chris
No one has to use the CLASSPATH I define, and so far it's working well. If a particular package becomes a problem, then we can figure out if we want to exclude it from the scheme or not. Right now we don't have xalan.jar or xerces.jar in the /usr/local/jars directory.
Also, this is not a huge multiuser system... Only 12 users in one workgroup, so communication is not as big an issue as if it were a 100 user system.
That said, I am worried that someone might request that a jar be updated only to find that it breaks someone else's application. In that case, I'm not sure what we could do to consolidate. For that jar we would probably stick with the old version and the user who needs the new version would manually use the new version.
Right now only 5 of the users (including myself) are using the csh script, and no one is using the bash one.
Chris
[ October 08, 2003: Message edited by: Chris De Vries ]
16 years ago
I administer a linux box with many java users. I noticed that many users downloaded several jakarta projects or other open source projects and included the relevant jars in their own directories, and manually edited their CLASSPATH each time they added a jar. I decided to make a central repository (/usr/local/jars) for all the jars, and make a csh script to automatically set the classpath as well as some other variables. I figured I would share it in case anyone else wants to use it, translate it to bash, or offer suggestions.
I have put this in /etc/javasetup.csh:

And now all I have to do to add more jars is to either move it into /usr/local/jars or make a symbolic link from /usr/local/jars to the package. All users can include the line "source /etc/javasetup.csh" in their .cshrc file. It also allows me to update the jdk and merely change one line in the javasetup.csh to allow all users to use the updated jdk.
I have tried making a sh/bash script too, though my knowledge of bash is limited.

Please feel free to use/modify/point out any bugs or platforms where these don't work. Or offer suggestions on what you have done differently.
Chris
16 years ago
At this point I would encourage you to read the documentation for both HttpClient and JBuilder. I have never used JBuilder, and I do not recall if you only need to download HttpClient jars or if other jakarta jars are also required, but I do know that it's all covered in the scant documentation.
Chris
You don't have to start to registries, you can use one rmiregistry and bind the remote objects from the two separate JVMs to that registry using the Naming.rebind() or Naming.bind() methods.
Chris
16 years ago
The Java API docs are a good place to go if you want to find out more about a method call.
Calendar.set(int,int,int,int,int,int) is documented there. The arguments are year, month (starting with 0), date, hour, minute, and second.
[ October 06, 2003: Message edited by: Chris De Vries ]
16 years ago