Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignoring Compilation errors - Java

Tags:

java

command

I have around 1500 files to compile, in which 15-20 files have compilation errors. These files are not under my control, so I could not do any modification/update/delete. So, i have two questions here.

1) how do i ignore the compilation errors from these 15-20 files and continue to produce the .class file for rest of them. is there any javac commandline option or anything which will ignore the compliation errors and produce the .class files for all other non error files.

2)will the java compiler abort compilation as soon as it sees these errors or will it continue compiling(producing .class files) everything else and at the end then complain about these files with errors.

like image 361
ajay Avatar asked Sep 28 '11 22:09

ajay


People also ask

How do I compile an ignoring error in Java?

Go to Build, Execution, Deployment | Compiler | Java Compiler and set the Use compiler: combobox to Eclipse and enable the proceed on errors checkbox. This allows to compile classes even when they have errors.

How do you overcome compilation errors?

If the brackets don't all match up, the result is a compile time error. The fix to this compile error is to add a leading round bracket after the println to make the error go away: int x = 10; System.

What causes compilation errors?

Compilation error refers to a state when a compiler fails to compile a piece of computer program source code, either due to errors in the code, or, more unusually, due to errors in the compiler itself. A compilation error message often helps programmers debugging the source code.

Why is my Java program not compiling?

It means that javac.exe executable file, which exists in bin directory of JDK installation folder is not added to PATH environment variable. You need to add JAVA_HOME/bin folder in your machine's PATH to solve this error. You cannot compile and run Java program until your add Java into your system's PATH variable.


1 Answers

You cannot ignore compile errors. They will always fail the build.

Your only choices are to talk to whoever controls the files to get them fixed or find a way to otherwise replace them.

If you try to remove them from the build, you will also have to remove any files that use those files. For example

class A {
    B b;
}

If B has a compile error, your build script can skip B.java, but when you hit A.java, it's going to try to compile B anyway, so A has to be removed. This may prove to be a non-trivial task.

like image 125
corsiKa Avatar answered Sep 17 '22 10:09

corsiKa