Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!

Bruce Wingate

Ranch Hand
+ Follow
since Feb 16, 2001
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 Bruce Wingate

I'm trying to load up the mysql jdbc driver, which is mm.mysql-2.0.11-you-must-unjar-me.jar. Every time I try to unjar it, it just hangs. I'm able to open it using winzip, but not unjar it.
Beyond the obvious of using WinZip, any suggestions?
Java In a Nutshell
I haven't read this one, but in general, I found the nutshell books good, but not for learning. They work best when you have some basis in the language/topic so that you know where to start from.
Bruce.
19 years ago
PL/1 -- holy cow, old languages do never die!!
I'm still on the fence about not-logic. There are some instances where it is easier and makes sense, and others where it is just old habit.
We have some horrendous code that uses not-named variables with not logic

The genius who coded that was also not consistent with how he loaded the variable. So notFinished=False could mean it was finished or not finished, depending on his whims.
As per your code, I try to avoid null code blocks, and when I use them, I make sure to put a comment in saying that I know it is blank.
Bruce.
19 years ago
I'm working with O'Reilly's "Java Servlet Programming", Chapter 9, Database Connectivity.
The examples have methods that catch a ClassNotFoundException which then throw a UnavailableException. My compiler says that UnavailableException is deprecated. How would I go about finding a suitable replacement for UnavailableException?
A snippet of code is:

So, I guess I have 2 questions: What should I be throwing? and How would I go about finding that out on my own?
Thanks
Bruce.
19 years ago
I use WinZip, but PKZip or gunzip should work fine. You might need to play with the extensions for gunzip.
19 years ago
All input from the command line is a string, so "java Calculate 3+2" has an args.length == 1 and arg[0] = "3+2". arg[1] and arg[2] are undefined (array index out of bounds.)
You'll probably want some intermediate step(s) that will take 3+2 and parse it into 3, +, and 2. I'm still beginning with java, but you will want to parse the input string(s) into indivual strings of operators and operands. I don't know the method that will do this, you'll have to hunt around.
19 years ago
A quick guess is that either there is no main with the signature of

or that the class name does not match the file name
or that you are not running it as "java FILENAME" (maybe you're trying "java FILENAME.class" or "java FILENAME.java"
19 years ago
So, if the constant is constant, like PI, Gravity on earth, the speed of light in a vacuum, then its OK to capitalize it, but if the constant is line length, page length, or number of connections allowed, then its not really a constant, so it should not be in all caps. I can deal with something like that.
I'm still trying to get myself out of Hungarian notation and inital caps for functions.
I'm rather pleasantly surprised with the style guide. I've developed my own style over these many years of coding, and the only real eye-opener was spaces around identifiers, but it makes sense when you need to search for a variable.
19 years ago
I'll expand on what Cindy said: It's OS dependent. If you want to find a CD-ROM drive or a floppy, you will need to call out of Java to the native operating system. To do this, I think that you would use JNI, but I am not really sure.
Windows has a couple of API calls that will help you deduce what drive might be a CD-ROM, but you cannot be sure, unless there are additional new functions I am unaware of. From what I remember, the function would return a drive letter and the type of drive, either fixed or removable. You could guess that a removable drive higher than C: is a CD-ROM, but then you could be wrong with Zip drives.
Unfortunately, I don't know the function name off-hand, but a check thru Microsoft's site or Petzgold's book should turn it up.
19 years ago
For consistency, and ease of reading the loops, I always start my loops at 0, unless I'm going backwards. Another rule I follow is to never modify the loop variable in a for loop. Technically you're not modifying the loop variable, but doing the modulo to it is close.
Maybe using a temp variable would clean things up?
19 years ago
The file name mix-up was just a typing error in my message.
I'm running JRun at home instead of Tomcat, but that should not affect the compiling if the jar with the servlet info is in the path. (In my case, the javax.servlet stuff is in jsdk.jar, which is in the jdk1.3 directory.) My regular java programs compile fine, and the src.jar is also in the jdk1.3 directory.
Any other suggestions?
19 years ago
I have set my classpath to "c:\jdk1.3;." and tried to compile what should be a textbook "hello world" servlet.
When I compiled it using "javac HelloWorld.java", I got a lot of errors like "import javax.servlet.*;" not found. These looked like classic Classpath problems, but I triple checked the class path, and it is correct. When I compile with "javac -extdirs c:\jdk1.3 Hello.java" it works no problem.
Any ideas? I'm going to reboot again and try redoing everything.
19 years ago
I'm using a developer version of JRun at home, and its pretty good. The advantage I see with JRun is that it is a commercial product (limited to 5 connections I think), so you get experience with a commercial product, and if you are using it in pre-production testing, you can scale up to a full server version with the simple application of money.
19 years ago
Bitwise operators are really good when you need to get small size or high performance. There are a lot of places where you could use it, but to be really honest, you wouldn't be using Java then.
19 years ago
Vectors hold Objects, and oddly, the integer type is not an object. You can get around this by using the class Integer and then casting it to int. You might be able to cast it explicity from Object to int.
Bruce.
19 years ago