Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Java compiler errors (http://www.velocityreviews.com/forums/t638713-java-compiler-errors.html)

Jozza 10-07-2008 10:07 AM

Java compiler errors
 
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



Evans 10-07-2008 10:15 AM

Re: Java compiler errors
 
On 7 Oct, 11:07, "Jozza" <h...@hmm.com> 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 10-07-2008 10:22 AM

Re: Java compiler errors
 
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" <onyxtic@gmail.com> wrote in message
news:0d981f03-6022-4209-8c95-13136a61f644@m3g2000hsc.googlegroups.com...
> On 7 Oct, 11:07, "Jozza" <h...@hmm.com> 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




Jan Thomä 10-07-2008 10:34 AM

Re: Java compiler errors
 


On 2008-10-07 12:22:39 +0200, "Jozza" <hmm@hmm.com> 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 10-07-2008 10:42 AM

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

Thanks everyone


"Jan Thomä" <janthomae@janthomae.de> wrote in message
news:6l0s9vFa4j1qU1@mid.individual.net...
>
>
> On 2008-10-07 12:22:39 +0200, "Jozza" <hmm@hmm.com> 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 10-07-2008 12:25 PM

Re: Java compiler errors
 

"Lew" <noone@lewscanon.com> wrote in message
news:EMGdnZXe0cmwznbVnZ2dnUVZ_jKdnZ2d@comcast.com. ..
> 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



Daniel Pitts 10-07-2008 02:31 PM

Re: Java compiler errors
 
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/>

Mark Space 10-07-2008 03:35 PM

Re: Java compiler errors
 
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.



Jason Cavett 10-07-2008 03:36 PM

Re: Java compiler errors
 
On Oct 7, 6:07*am, "Jozza" <h...@hmm.com> 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.

Tom Anderson 10-07-2008 05:28 PM

Re: Java compiler errors
 
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


All times are GMT. The time now is 07:15 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.