understanding javac command
hi,
canu tell me how javacompiler compiles the java program that means on which bases it will give error and exceptions.
Generally we will get exceptions when we run .class file but we are getting exception when we compile java program, did u get it.how it possible
regards
Guru
The Java compiler is (usually) a Java program itself. It's job is to read .java files and output .class files. Just like any other Java program, if it encounters a problem--or if there's a bug in the compiler itself--it may throw an exception.
Exceptions always occur during runtime. Some of them occur when running the compiler program, and some occur when running your program.
jverda at 2007-7-14 20:40:51 >

Well,the exception due to error in coding, what is your program all about?Post the coding of line which is generating error.
Hi jverd,As u said java compiler is a java program so it will give exceptions when it read java file at run time.But we r getting errors also when the java compiler compiles java program.Can u explain clearlyRegards Veeru.N.V
What part of his explanation did you not understand?The compiler is itself a java program. Therefore, it can throw exceptions.Of course, another possibility is that you haven't correctly interpreted what's going on.
hi,my doubt is that java compiler is a javaprogram so it will throw exceptions .Generally java program will not give errors at runtime.But javacompiler will give errors also at runtime. i am getting confusion at this step.regardsGuru
What? Java programs can easily give errors at runtime. That's what exceptions are for. Maybe if you're just starting out you'll be dealing with a lot of syntax errors that'll bother you during compile time, and that would create the illusion that errors are a compile-time problem. But as you develop more you'll find that stuff that the compiler finds for you are really just typos. The real bugs happen at runtime.
Anyway, this seems like the exact opposite of what you were saying earlier.
Generally, you don't get exceptions during the compile process, because the compiler is well-tested and anticipates things that can go wrong, so problems are caught before any exceptions are thrown (or at least, few exceptions bubble up to the user interface). However, it is possible for an exception to appear during compilation.
Are you actually getting a real exception during compilation? If so can you post it and post the manner in which you're invoking javac?
> Hi jverd,
>
> As u said java compiler is a java program
> so it will give exceptions when it read java file at
> run time.But we r getting errors also when the java
> compiler compiles java program.Can u explain
> clearly
I thought I did explain it clearly. Compile time for your program is runtime for the Java program that is the compiler. It gives exceptions at its runtime (compiling your .java files into .class files) just as your program will give exceptions at its runtime (taking whatever input it takes [like javac's .java files] and processing it to produce its output [like javac's .class files]). What do you not understand?
jverda at 2007-7-14 20:40:51 >

hi,i have no problem with javacompiler .i want to know the behaviour of java compiler when it convert .java file to .class fileregardsGuru
Compile time exceptions are different than runtime exceptions.
How would you expect this to compile?
public doubt silly exaggerates pointless{
public clown static({
cout >> "My pointer fell down the rabbit hole!"
}
}
I think it might be easier to understand you if you give an example of one of these exceptions.
> I think it might be easier to understand you if you
> give an example of one of these exceptions.
Okay...
See previous reply.
javac silly.java
silly.java:1: 'class' or 'interface' expected
public doubt silly exaggerates pointless{
^
1 error
That's not an exception, that's an error message.
> That's not an exception, that's an error message.Do you really think veeru_mca2005@gmail.com knows the difference?
Nope. Which is why I want him to actually post the $&#*ing thing.
> hi,
>
> i have no problem with javacompiler .i want to know
> the behaviour of java compiler when it convert .java
> file to .class file
>
> regards
> Guru
What do you mean?
The behavior is whatever you observe. If there's a syntax error in your .java file, the compiler will give you a descriptive message about where it occured and what kind of error it is. If there's a bug in the compiler itself or if it runs out of memory, it will throw its own exception.
It's not at all clear what your question is.
jverda at 2007-7-21 10:00:55 >

>Okay...>See previous reply.Oh, sorry, I was talking to the person who started the thread.