Albert Park

Greenhorn
+ Follow
since Feb 01, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
4
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Albert Park

Hello everyone,

I know this was brought up many times before. I just can't seem to figure out what the problem is.
Tomcat works fine when I run localhost:8080.
But this error keeps coming up everytime I start tomcat.
I am not using IDE. I am starting tomcat directly from bin.
I have tried different port number in server.xml, also got a fresh tomcat, checked netstat make sure nothing is running before I start, tried restarting my computer, checked that java isn't running in process.
Also tried with tomcat 6.
But none of these help me get rid of socket bind failed that comes up in console.

The problem I have is that I am trying to test ssl, but it isn't working. Mind you I literally tried everything online.
I am assuming that this socking bind error is the root of the problem.

Here is my log of fresh Tomcat7 without any changes to xml.

10 years ago
Hello, if this is a wrong section in the forum I apologize.
I am learning java and in the mean time learning about selenium webdriver, so bear with me.
I am playing with selenium webdriver to see if I can use it to test simple web browser.
However, I ran into a problem when I try to build a sample class that extends to super class to help me simplify things.
For example, verifying element present.



here is part of my subclass that actually runs the test.



So verifyLink method doesn't work correctly and always shows test passed.
So I know this way is making me use the driver in superclass and my subclass won't even throw an error when the test runs.
I want to make it so my subclass inherits the methods that I need, and use my own Webdriver object that is from subclass to make the test fail, when it should.
Can someone guide me to the correct design of creating a helper class.

Thanks in advance.
10 years ago

Campbell Ritchie wrote:Which class has the setRadius method which actually declares that Exception?

I know you are only doing this as a “what happens if” exercise, which permits you to try anything short of deleting every file on your hard drive, but in real life you would do at least three things differently:-

  • 1: Not give the radius to the exception as a field.
  • 2: Not make that exception checked.
  • 3: Use java.lang.IllegalArgumentException instead.


  • ok. I followed your first two advice and it works.
    And yes, I got the correct compile error which made this work.

    Thank you for making me think
    10 years ago

    Campbell Ritchie wrote:Which class has the setRadius method which actually declares that Exception?

    I know you are only doing this as a “what happens if” exercise, which permits you to try anything short of deleting every file on your hard drive, but in real life you would do at least three things differently:-

  • 1: Not give the radius to the exception as a field.
  • 2: Not make that exception checked.
  • 3: Use java.lang.IllegalArgumentException instead.


  • sorry about that, I fixed the code, but instead I get a red underline inside my constructor in CircleWithException class.
    Yes, if I just use IllegalArgumentException, it works fine.
    But the book wants me to create a custom exception to handle this.
    10 years ago
    Hello again,
    I am learning about exception and I can't figure out why Eclipse is giving me this message.

    I have created an exception class extends Exception , a CircleWithException class to see if my exception works.
    If I am doing it correctly, eclipse should recognize my exception class and should work, since InvalidRadiusException class is now a subclass of Exception.
    Any help would be great.

    Thanks in advance.

    This is my exception class.


    10 years ago

    Jeff Verdegan wrote:

    Albert Park wrote:
    So we can replace the last line with Rectangle2D bounds = f.getStringBounds(message, new FontRenderContext())?



    If that constructor is accessible, and if all the method does is create a new FRC using that constructor, then yes.

    However, if the method pulls an existing FRC from a cache, or invokes a different constructor, or does some initialization after creating it and before returning it, then, no, we can't just replace the method call with the constructor.

    In fact, there's nothing special about constructors in this situation. In general, we can't replace a method call with some other code unless that code does the same thing as what's in the body of the method.

    What exactly is getFontRenderContext method returning here other than making a new object of FontRendercontext class?



    We don't know and we don't care, beyond what the documentation tells us. This is one of the reasons for methods to exist--so that we can separate what the operation is (get me an FRC) from how it's done (create a new one, initialize it a certain way, or return one from a cache). And then we can change the "how" without changing the "what" if there's a good reason to do so.



    hmm.. so I should just memorize this whenever I need to reference to bounds related object(which requires FontRenderContext referenced object required in parameter) from Graphics.
    But I do understand the difference of these two I was confused about earlier.
    Really appreciate both of your help!.
    10 years ago
    Ok, I think I am kind of getting it.
    I need to think about this more...

    This is what javadoc says
    public abstract FontRenderContext getFontRenderContext()
    Get the rendering context of the Font within this Graphics2D context. The FontRenderContext encapsulates application hints such as anti-aliasing and fractional metrics, as well as target device specific information such as dots-per-inch. This information should be provided by the application when using objects that perform typographical formatting, such as Font and TextLayout. This information should also be provided by applications that perform their own layout and need accurate measurements of various characteristics of glyphs such as advance and line height when various rendering hints have been applied to the text rendering.

    So we can replace the last line with Rectangle2D bounds = f.getStringBounds(message, new FontRenderContext())? only if FontRenderContext constructor in FontRenderContext class was not protected?
    Then isn't it pretty much same as creating a new object like the employee one?

    What exactly is getFontRenderContext method returning here other than making a new object of FontRendercontext class?

    Someone stop me before I confuse the heck out of myself.
    10 years ago
    Please help me understand this.
    Here is the part of the code.



    so the part that confuses me is that "context" is a variable that holds an FontRenderContext object type and assigned a value(FontRenderContext type) returned from getFontRenderContext() method in Graphics2D class.
    Is this different OR same concept as creating an instance of an object from a subclass?
    Person person1 = new Employee();
    When Employee class extends Person class.
    How are these two differ?

    This is quite confusing. Thanks in advance!
    10 years ago

    Mansukhdeep Thind wrote:

    Winston wrote: There are occasions when getClass() is necessary, but to be honest, I'm surprised that a book is teaching it as the standard approach.



    I am curious which book are you studying from. If you learn the wrong methodologies in the first go as a beginner/novice, they leave an imprint on the brain that becomes difficult to erase when you actually get to the correct stuff. Better get your hands on a book which takes the correct approach.



    Hello, I am using Core Java Volume-I 8th edition.
    I read good reviews from amazon.
    I also went over introduction to java programming by liang.
    Can you guys recommend any java books?
    10 years ago
    ahh. Got it.

    Thanks!
    10 years ago
    Hello I am going over Core java book.
    Here is the code that I don't understand.



    What is the differecen between (this == otherObject) and (getClass() != otherObject.getClass())?
    If I am correct, the first condition checks the reference of two objects and the second condition checks if both objects belong to the same class.
    From my understand, if an object has a same reference as another, then can't we safely assume that they are from same class(Is this to check if the object is belong to a subclass)?
    Please let me know how they differ and if not, why do we have to check the same condition twice?

    Thanks.
    10 years ago
    ahh,
    Nvm. Got everything wrong.
    You can't use those methods when you use List.
    Thanks for your help.
    10 years ago
    Hello,
    I am learning about collection framework, and little lost here.
    Apologize for my ignorance in advance.
    I know we can write,

    List<String> list = new LinkedList<String>();

    I learned that LinkedList extends AbstractList, and that AbstractList implements List interface.
    Since List interface also extends to Collection interface,
    Why can't I create,

    Collection<String> list = new LinkedList<String>();
    and access those methods in LinkedList such as addFirst, addLast etc, without having to cast?

    Is it because of some sort of interface rule that Collection interface is not directly related to LinkedList?
    10 years ago

    Steve Fahlbusch wrote:

    The reason why i created reverse method was to print the letters in the right order. My commonSuffix method compares their suffix from right to left, so if i just print that out, it will print backwards.



    That is obvious, but why??? Why do what is provided by the language?



    ahhh ic. I am learning from the text, "Introduction to java programming" and the text wants me to come up with that on my own. I haven't learn the reverse method stored in java yet.
    so yea, I just learned something new! haha
    sorry for my ignorance...
    11 years ago
    Thanks for the advice.
    The reason why i created reverse method was to print the letters in the right order. My commonSuffix method compares their suffix from right to left, so if i just print that out, it will print backwards.
    11 years ago