Paul Clapham

Sheriff
+ Follow
since Oct 14, 2005
Paul likes ...
Eclipse IDE Firefox Browser MySQL Database
Vancouver, Canada
Cows and Likes
Cows
Total received
56
In last 30 days
1
Total given
114
Likes
Total received
2551
Received in last 30 days
9
Total given
612
Given in last 30 days
8
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Paul Clapham

Jesse Wiatrak wrote: I'm just trying to determine if removing all strings that aren't composed entirely of valid English words...



How would you do that? Well, it seems to me that you'd need to be able to identify a "valid English word". And for that you'd need a list of those words. You can probably find examples of that on the web, but make sure they include all grammatical variants like plurals (cat vs cats, mouse vs mice) and verb tenses (believe vs believed vs believing, eat vs ate vs eaten vs eating). And cross your fingers and hope that your ciphertext doesn't have misspeled words and doesn't use superunusual words.

And then to examine a string to see if its a concatenation of the words in your list, the algorithm isn't all that straightforward. Sure, an algorithm does exist but it involves more than just scanning from left to right.
3 days ago

Cliff Black wrote:... I have to work on my Maths in general maybe a bit more...



I'm a math guy and I noticed right away that if i and j are positive integers then j <= j/i is only true when i = 1. But of course you were struggling with for-loop mechanics and code indentation and so on, so that sort of thing would be the last thing you noticed. When you're debugging code the brain gets very focused, trust me, I know.

On the other hand, I've been writing programs for many years now and I never ever needed to know anything about prime numbers while writing those programs. Teachers give that sort of assignment because it's a non-trivial use of loops so it's presumably helpful for people learning about loops.
3 days ago
Yeah, that's very true. But here's my opinion:

The top panel (Panel 1) looks like it's meant to have several button controls in it, so it wants to be fixed height, and maybe the rest can expand and contract without problems. So to me it looks like a vertical BoxLayout containing two JPanels.

Basically those two JPanels may or may not change size, depending on what controls are inside them. Normally JButtons are of fixed size, so stretching the frame won't affect the height of a JPanel which contains them (assuming you choose a normal layout for that JPanel).

So for a start I would try BoxLayouts all the way down. One to contain Panel 1 and the rest, then one to contain Panel 2 and the stuff to the right of it, then one to contain Panels 3 and 4. And yeah, there might be better choices for the last two, but implementing the all-BoxLayout idea and trying it out ought to clarify your ideas about how the whole frame should work when stretched.
4 days ago

Cliff Black wrote:The book has the code exactly as you saw it,  ( j <= i/j)



Although the code you posted just above that had something different:



There's some confusion there, but maybe it's mine. I didn't think the previous posts specifically discussed that division as an issue, but it's quite possible that I missed that.
6 days ago
Just guessing, but maybe axis2 doesn't know about the package.
1 week ago
If the source code for Test doesn't include an import statement for ServiceClient, that just means that Test and ServiceClient are in the same package. They are in a package, aren't they?
1 week ago
Now that I think about it more, it's not a flaw. In fact you basically have to use reflection -- or at least the loadClass method of ClassLoader -- to get an instance of a class which was loaded by that ClassLoader. So it's not that it doesn't buy you anything, which is what I originally said. It's that you have to do it that way anyway.

Also bear in mind that every object contains a reference to the class which it's a member of. And every class contains a reference to the classloader which loaded it. So to unload a classloader you need to get rid of references to all objects in classes which were loaded by that classloader.

And this special Class which is loaded by your special ClassLoader: it has to be a subclass of some class which your compiler knows about. (Or implement an interface which your compiler knows about.) That means a class or interface which can be loaded at run time by the standard classloader. Or maybe that's where you planned to use reflection? I suppose you could do that, it's very clumsy, but it doesn't solve any garbage collection problems.
1 week ago
Yes, your initial impression is correct. To have the special classloader unloaded, you need to not have any references to objects which it loaded. But I think your reflection idea is flawed: if you create objects that way and have them be the ones from your special class, then they will still have a reference to its class object. So you'd still have to deal with getting rid of them before the special class could be garbage collected.

I worked with a system (not written by me) which would automatically reload classes when a new version of a jar file appeared in a certain location, and it used the technique of creating a special classloader to do that. It's been a long time since I worked with it at that level but if I recall right, the technique was that you'd get one special object from the special class and your application code would only use that object. Of course it would produce more objects from the special class and use them for doing whatever it did, but your application wouldn't have references to those objects. That way when you stopped holding a reference to the special object, it and all of the objects it used would then be available for garbage collection. As would the special class (after all objects in that class were GC'ed) and presumably the special classloader.

It was a complex system and it had its memory issues, but it didn't use increasing amounts of memory as classes were reloaded. The base memory usage did stay constant over time.

1 week ago

Joseph Michael wrote:This is not a XML...Just a user alphabetical character string..Where SOH is exist in start of the string or middle of the string or in the end of the string...How to restrict this in Java?



The way to restrict it is to have your text box ignore that character. Probably... but you haven't told us what kind of text box it is so I couldn't tell you how to do that. Or you could just delete that character from wherever it appears in the strings you're getting.
1 week ago

Joseph Michael wrote:What would be the best approach in this case?



Presumably the user can paste any text, which might or might not be well-formed XML. You could take the approach of rejecting all inputs which are not well-formed XML... that puts the burden on the user to make sure they are only posting valid input.

On the other hand if this particular solution happens regularly you should look into the copy-paste process to find out what's going on. I can't see somebody posting an XML document from a cell in Excel and if they did I can't see it containing unprintable characters like the one you are having trouble with. Maybe there's something funny about these text boxes, which you still haven't told us what kind they are. Swing? Javascript? Something else?
1 week ago
It would help if we knew what kind of "texbox" you were asking about. And also what a "header" is in that context.
1 week ago

Ana Yo wrote:Should I use only one scanner the whole program



No. Your design with two scanners is perfectly fine.

and which should I delete?



You shouldn't delete either of them. To the contrary, you should use both of them. Your existing code doesn't do that.

Use one scanner to read from System.in and ask for the file name. Use the other one to read from that file.
1 week ago


Notice that you set up a Scanner to read from the file that was chosen. Then you want to use it to read from that file... but instead you read from the Scanner where you asked for the file name.
1 week ago

Todor Kolev wrote:Also, the question is about Maven, not eclipse or an unknown plugin host



So I've moved your post to the Maven forum.
1 week ago

André Fagundes wrote:not working



This could mean anything from "I don't know what code to write" to "My app crashes and then I have to buy a new computer". Could you be a bit more specific about what you can do and what you can't do?
1 week ago