Java compiler errors

J

Jozza

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
 
E

Evans

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 ...
 
J

Jozza

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.
 
J

Jan Thomä

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
 
J

Jozza

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

Thanks everyone
 
J

Jozza

Lew said:
Please do not top-post.
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.

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

Daniel Pitts

Jozza said:
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.
}
}
 
M

Mark Space

Jozza said:
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.
 
J

Jason Cavett

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.
 
T

Tom Anderson

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
 
R

RedGrittyBrick

Jozza said:
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
 
P

Patricia Shanahan

RedGrittyBrick said:
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
 
R

Roedy Green

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top