Java compiler errors

Discussion in 'Java' started by Jozza, Oct 7, 2008.

  1. Jozza

    Jozza Guest

    Hey all,

    I don't know if this is the right group, but heres my problem with java
    compiler.

    I'm using eclipse ide and i get this wierd errors if i dont include
    statements in try...catch or if the compiler figures out that some variable
    might not have been initialized. I need to turn this checking off! I dont
    want to be treated like a fool by the compiler.
    I checked all the settings in eclipse but cant find anything appropriate.

    Help?

    TIA, Jozza
    Jozza, Oct 7, 2008
    #1
    1. Advertising

  2. Jozza

    Evans Guest

    On 7 Oct, 11:07, "Jozza" <> wrote:
    > Hey all,
    >
    > I don't know if this is the right group, but heres my problem with java
    > compiler.
    >
    > I'm using eclipse ide and i get this wierd errors if i dont include
    > statements in try...catch or if the compiler figures out that some variable
    > might not have been initialized. I need to turn this checking off! I dont
    > want to be treated like a fool by the compiler.
    > I checked all the settings in eclipse but cant find anything appropriate.
    >
    > Help?
    >
    > TIA, Jozza


    Note that if your code is likely to throw an exception and you didn't
    put it with the try/catch to handle the exception, there's no way you
    will be allowed to successfully compile or run that code.

    If I may ask, why would you want to avoid adding the try/catch when
    you know it's needed?
    Hmm, smells like a ...

    --
    Evans
    http://www.jroller.com/evans
    Evans, Oct 7, 2008
    #2
    1. Advertising

  3. Jozza

    Jozza Guest

    It comes to that when i want to fast write/copy some code to try something
    out and i lose time with securing every statement.
    Its very annoying and i'm not used to that at any other language, so i want
    to turn this part of java compiler's brain off, at least when i want to. You
    know ...

    J.

    "Evans" <> wrote in message
    news:...
    > On 7 Oct, 11:07, "Jozza" <> wrote:
    >> Hey all,
    >>
    >> I don't know if this is the right group, but heres my problem with java
    >> compiler.
    >>
    >> I'm using eclipse ide and i get this wierd errors if i dont include
    >> statements in try...catch or if the compiler figures out that some
    >> variable
    >> might not have been initialized. I need to turn this checking off! I dont
    >> want to be treated like a fool by the compiler.
    >> I checked all the settings in eclipse but cant find anything appropriate.
    >>
    >> Help?
    >>
    >> TIA, Jozza

    >
    > Note that if your code is likely to throw an exception and you didn't
    > put it with the try/catch to handle the exception, there's no way you
    > will be allowed to successfully compile or run that code.
    >
    > If I may ask, why would you want to avoid adding the try/catch when
    > you know it's needed?
    > Hmm, smells like a ...
    >
    > --
    > Evans
    > http://www.jroller.com/evans
    Jozza, Oct 7, 2008
    #3
  4. Jozza

    Jan Thomä Guest

    On 2008-10-07 12:22:39 +0200, "Jozza" <> said:
    >> Note that if your code is likely to throw an exception and you didn't
    >> put it with the try/catch to handle the exception, there's no way you
    >> will be allowed to successfully compile or run that code.
    >>
    >> If I may ask, why would you want to avoid adding the try/catch when
    >> you know it's needed?
    >> Hmm, smells like a ...


    > It comes to that when i want to fast write/copy some code to try something
    > out and i lose time with securing every statement.
    > Its very annoying and i'm not used to that at any other language, so i want
    > to turn this part of java compiler's brain off, at least when i want to. You
    > know ...



    The Java language specification enforces that checked exceptions are
    either to be thrown or catched. There is no way to disable this, it is
    part of the Java language. There are basically two ways to get a quick
    hack:

    public void myMethod() throws Exception {

    whatever code you write here needs no try/catch
    }

    or better. get some decent java editor which quickly produces try/catch
    statements for you. About possibly uninitalized variables, you will
    have to fix this up, there is no way to suppress this check.


    Jan
    Jan Thomä, Oct 7, 2008
    #4
  5. Jozza

    Jozza Guest

    Ok then,
    I guess i will have to comply to the terms of Java compiler. LOL :))

    Thanks everyone


    "Jan Thomä" <> wrote in message
    news:...
    >
    >
    > On 2008-10-07 12:22:39 +0200, "Jozza" <> said:
    >>> Note that if your code is likely to throw an exception and you didn't
    >>> put it with the try/catch to handle the exception, there's no way you
    >>> will be allowed to successfully compile or run that code.
    >>>
    >>> If I may ask, why would you want to avoid adding the try/catch when
    >>> you know it's needed?
    >>> Hmm, smells like a ...

    >
    >> It comes to that when i want to fast write/copy some code to try
    >> something
    >> out and i lose time with securing every statement.
    >> Its very annoying and i'm not used to that at any other language, so i
    >> want
    >> to turn this part of java compiler's brain off, at least when i want to.
    >> You
    >> know ...

    >
    >
    > The Java language specification enforces that checked exceptions are
    > either to be thrown or catched. There is no way to disable this, it is
    > part of the Java language. There are basically two ways to get a quick
    > hack:
    >
    > public void myMethod() throws Exception {
    >
    > whatever code you write here needs no try/catch
    > }
    >
    > or better. get some decent java editor which quickly produces try/catch
    > statements for you. About possibly uninitalized variables, you will have
    > to fix this up, there is no way to suppress this check.
    >
    >
    > Jan
    >
    >
    >
    Jozza, Oct 7, 2008
    #5
  6. Jozza

    Jozza Guest

    "Lew" <> wrote in message
    news:...
    > Please do not top-post.
    >
    > Jozza wrote:
    >> It comes to that when i [sic] want to fast write/copy some code to try
    >> something out and i [sic] lose time with securing every statement.
    >> Its very annoying and i'm [sic] not used to that at any other language,
    >> so i [sic] want to turn this part of java compiler's brain off, at least
    >> when i want to. You know ...

    >
    > This is required by the language itself. You cannot turn it off. Java is
    > a strongly-typed language. Its very style is to check everything and to
    > prevent at compilation time certain types of errors, like unreachable
    > statements, unhandled checked exceptions or uninitialized variables (not
    > "definitely assigned").
    >
    > That's Java, folks. If you don't like it, use BASIC and put up with
    > buggy, fragile code.
    >
    > --
    > Lew


    Oki doke, Lew, but i'll need to know why is top-posting bad
    Jozza, Oct 7, 2008
    #6
  7. Jozza

    Daniel Pitts Guest

    Jozza wrote:
    > Ok then,
    > I guess i will have to comply to the terms of Java compiler. LOL :))


    if you want to run a quick snippet, and don't want to deal with
    exceptions, then you can use this idiom:

    public class Scratch {
    public static void main(String...args) throws Exception {
    // Code to run.
    }
    }

    --
    Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
    Daniel Pitts, Oct 7, 2008
    #7
  8. Jozza

    Mark Space Guest

    Jozza wrote:

    > Oki doke, Lew, but i'll need to know why is top-posting bad


    It's common netiquette to not top post. Check out some of the
    netiquette guides, they really do say it.

    It does help with readability. In-line quoting is better. OTHOH, if
    you want to just reply in general and not quote, trim the entire
    previous post out, and just write a plain reply with no quoting at all.
    That works and is probably easier on you too.

    My big thing is trimming quotes. I really hate reading 200 lines of
    multi-quoted post just to find a 1 line reply at the bottom. It's a
    great waste of time for all the readers, and there are usually at least
    a dozen or so folks reading any given post.

    Most news reader arranges posts into threads, so quoting just for
    following the flow of conversation is unnecessary. Trimming more out is
    usually better than leaving too much in, IMO.
    Mark Space, Oct 7, 2008
    #8
  9. Jozza

    Jason Cavett Guest

    On Oct 7, 6:07 am, "Jozza" <> wrote:
    > Hey all,
    >
    > I don't know if this is the right group, but heres my problem with java
    > compiler.
    >
    > I'm using eclipse ide and i get this wierd errors if i dont include
    > statements in try...catch or if the compiler figures out that some variable
    > might not have been initialized. I need to turn this checking off! I dont
    > want to be treated like a fool by the compiler.
    > I checked all the settings in eclipse but cant find anything appropriate.
    >
    > Help?
    >
    > TIA, Jozza


    As people have said, you have to handle exceptions in Java - it's part
    of the language.

    HOWEVER, within Eclipse, you can turn off compiling on the fly by
    going to "Project > Build Automatically" and making sure that option
    is unchecked. However, when you go to run the application, it will
    still give you errors.
    Jason Cavett, Oct 7, 2008
    #9
  10. Jozza

    Tom Anderson Guest

    On Tue, 7 Oct 2008, Jozza wrote:

    > I don't know if this is the right group, but heres my problem with java
    > compiler.
    >
    > I'm using eclipse ide and i get this wierd errors if i dont include
    > statements in try...catch or if the compiler figures out that some
    > variable might not have been initialized. I need to turn this checking
    > off! I dont want to be treated like a fool by the compiler.


    Luckily, Eclipse knows better than you - you evidently are a fool.

    The situation 'variable might not have been initialized' is an error,
    indicating invalid java code, and there is no java compiler which will let
    it pass, because it's quite simply not java. Turning that off is a
    meaningless thing to ask for.

    Even if you're talking about warnings rather than errors, turning them off
    is foolish. Fix your code so they don't arise. If there's a case where you
    can't, and you're *absolutely* certain that it won't be a problem, use
    @SuppressWarnings.

    tom

    --
    Wikipedia topics: lists of trains, Mortal Kombat characters, one-time
    villains from Mario games, road intersections, boring suburban schools,
    garage bands, cats, webcomics, Digimon, Bionicle characters, webforums,
    characters from English soap operas, and Mortal Kombat characters that
    don't exist -- Uncyclopedia
    Tom Anderson, Oct 7, 2008
    #10
  11. Jozza wrote:
    >
    > "Jan Thomä" <> wrote in message
    > news:...
    >>
    >> On 2008-10-07 12:22:39 +0200, "Jozza" <> said:
    >>>> Note that if your code is likely to throw an exception and you
    >>>> didn't put it with the try/catch to handle the exception,
    >>>> there's no way you will be allowed to successfully compile or
    >>>> run that code.
    >>>>
    >>>> If I may ask, why would you want to avoid adding the try/catch
    >>>> when you know it's needed?
    >>>>
    >>> It comes to that when i want to fast write/copy some code to try
    >>> something out and i lose time with securing every statement. Its
    >>> very annoying and i'm not used to that at any other language, so
    >>> i want to turn this part of java compiler's brain off, at least
    >>> when i want to. You know ...

    >>
    >> or better. get some decent java editor which quickly produces
    >> try/catch statements for you. About possibly uninitalized
    >> variables, you will have to fix this up, there is no way to
    >> suppress this check.

    >
    > Ok then, I guess i will have to comply to the terms of Java compiler.
    > LOL :))
    >


    I press Alt+1 for "Quick Fix" in Eclipse. It will then offer to do the
    necessary coding for you.
    - add try-catch around code that can throw an exception
    - add unimplemented methods
    (when extending abstract class or implementing interface etc)

    Other keyboard short-cuts I use a lot include ...
    Ctrl+Space for "Content Assist"
    - completes names of variable, class or method.
    - suggests parameters for method calls.
    Ctrl+Shift+O for "Organize Imports" (
    - adds any needed import statements.
    Ctrl+Shift+F to reformat (indent) my code.

    See http://eclipse-tools.sourceforge.net/Keyboard_shortcuts_(3.0).pdf

    In Eclipse:
    Ctrl+Shift+L
    Help, Tips&Tricks, Java Development




    --
    RGB
    RedGrittyBrick, Oct 7, 2008
    #11
  12. RedGrittyBrick wrote:
    >
    > Jozza wrote:
    >>
    >> "Jan Thomä" <> wrote in message
    >> news:...
    >>>
    >>> On 2008-10-07 12:22:39 +0200, "Jozza" <> said:
    >>>>> Note that if your code is likely to throw an exception and you
    >>>>> didn't put it with the try/catch to handle the exception,
    >>>>> there's no way you will be allowed to successfully compile or
    >>>>> run that code.
    >>>>>
    >>>>> If I may ask, why would you want to avoid adding the try/catch
    >>>>> when you know it's needed?
    >>>>>
    >>>> It comes to that when i want to fast write/copy some code to try
    >>>> something out and i lose time with securing every statement. Its
    >>>> very annoying and i'm not used to that at any other language, so
    >>>> i want to turn this part of java compiler's brain off, at least
    >>>> when i want to. You know ...
    >>>
    >>> or better. get some decent java editor which quickly produces
    >>> try/catch statements for you. About possibly uninitalized
    >>> variables, you will have to fix this up, there is no way to
    >>> suppress this check.

    >>
    >> Ok then, I guess i will have to comply to the terms of Java compiler.
    >> LOL :))
    >>

    >
    > I press Alt+1 for "Quick Fix" in Eclipse. It will then offer to do the
    > necessary coding for you.
    > - add try-catch around code that can throw an exception

    ....
    It also offers the alternative of adding a throws clause to the method
    declaration, passing the exception back to the caller. In quick hack
    code, that is often a better choice than catching it locally.

    Patricia
    Patricia Shanahan, Oct 7, 2008
    #12
  13. Jozza

    Roedy Green Guest

    On Tue, 7 Oct 2008 12:07:49 +0200, "Jozza" <> wrote, quoted
    or indirectly quoted someone who said :

    >Hey all,
    >
    >I don't know if this is the right group, but heres my problem with java
    >compiler.
    >
    >I'm using eclipse ide and i get this wierd errors if i dont include
    >statements in try...catch or if the compiler figures out that some variable
    >might not have been initialized. I need to turn this checking off! I dont
    >want to be treated like a fool by the compiler.
    >I checked all the settings in eclipse but cant find anything appropriate.
    >
    >Help?
    >
    >TIA, Jozza
    >

    see http://mindprod.com/jgloss/compileerrormessages.html
    for what the errors mean, at least the Javac ones.
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com/politics/harper.html
    Anyone but Harper for Prime Minister of Canada
    Roedy Green, Oct 8, 2008
    #13
  14. Jozza

    Jozza Guest

    Yes, this seems like the bast/fastest solution

    Thx

    "Jan Thomä" <> wrote in message
    news:...
    >
    >
    > On 2008-10-07 12:22:39 +0200, "Jozza" <> said:
    >>> Note that if your code is likely to throw an exception and you didn't
    >>> put it with the try/catch to handle the exception, there's no way you
    >>> will be allowed to successfully compile or run that code.
    >>>
    >>> If I may ask, why would you want to avoid adding the try/catch when
    >>> you know it's needed?
    >>> Hmm, smells like a ...

    >
    >> It comes to that when i want to fast write/copy some code to try
    >> something
    >> out and i lose time with securing every statement.
    >> Its very annoying and i'm not used to that at any other language, so i
    >> want
    >> to turn this part of java compiler's brain off, at least when i want to.
    >> You
    >> know ...

    >
    >
    > The Java language specification enforces that checked exceptions are
    > either to be thrown or catched. There is no way to disable this, it is
    > part of the Java language. There are basically two ways to get a quick
    > hack:
    >
    > public void myMethod() throws Exception {
    >
    > whatever code you write here needs no try/catch
    > }
    >
    > or better. get some decent java editor which quickly produces try/catch
    > statements for you. About possibly uninitalized variables, you will have
    > to fix this up, there is no way to suppress this check.
    >
    >
    > Jan
    >
    >
    >
    Jozza, Oct 8, 2008
    #14
  15. Jozza

    Jozza Guest

    "Jozza" <> wrote in message news:gchn4i$r3v$...
    > Yes, this seems like the bast/fastest solution
    >
    > Thx
    >
    > "Jan Thomä" <> wrote in message
    > news:...
    >>
    >>
    >> On 2008-10-07 12:22:39 +0200, "Jozza" <> said:
    >>>> Note that if your code is likely to throw an exception and you didn't
    >>>> put it with the try/catch to handle the exception, there's no way you
    >>>> will be allowed to successfully compile or run that code.
    >>>>
    >>>> If I may ask, why would you want to avoid adding the try/catch when
    >>>> you know it's needed?
    >>>> Hmm, smells like a ...

    >>
    >>> It comes to that when i want to fast write/copy some code to try
    >>> something
    >>> out and i lose time with securing every statement.
    >>> Its very annoying and i'm not used to that at any other language, so i
    >>> want
    >>> to turn this part of java compiler's brain off, at least when i want to.
    >>> You
    >>> know ...

    >>
    >>
    >> The Java language specification enforces that checked exceptions are
    >> either to be thrown or catched. There is no way to disable this, it is
    >> part of the Java language. There are basically two ways to get a quick
    >> hack:
    >>
    >> public void myMethod() throws Exception {
    >>
    >> whatever code you write here needs no try/catch
    >> }
    >>
    >> or better. get some decent java editor which quickly produces try/catch
    >> statements for you. About possibly uninitalized variables, you will
    >> have to fix this up, there is no way to suppress this check.
    >>
    >>
    >> Jan
    >>
    >>
    >>

    >
    >

    Oopss,

    Me top-posting again, really sorry :)
    Jozza, Oct 8, 2008
    #15
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    942
    Mark Goldin
    Jan 17, 2004
  2. SenthilVel
    Replies:
    0
    Views:
    941
    SenthilVel
    Jun 7, 2006
  3. George1776

    Out-of-memory errors and caching errors.

    George1776, Aug 28, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    1,292
    George1776
    Sep 14, 2006
  4. Lance Wynn
    Replies:
    1
    Views:
    1,841
    Lance Wynn
    Feb 3, 2008
  5. kramer31

    java compiler errors on regexs

    kramer31, Jul 8, 2008, in forum: Java
    Replies:
    4
    Views:
    321
    kramer31
    Jul 11, 2008
Loading...

Share This Page