Java Linux problem or Java problem?
I am running Ubuntu 11.10. Running Java 7.0.1 with NetBeans. I wrote a java
program with a loop that reads a 26000 character text file (NVRAM.TXT) into
a character array. It worked fine. I ran the program numerous times over
four days. I have not made any changes to the java file. The program is
listed below. It has only 24 lines. Today when I run it, it has weird
errors referenced toline numbers 2442, 2685 and 1620. When I click on those
error messages it shows lines in
a huge completely different program - a program that I never wrote. I cut
and pasted the source (24 lines) of the offending file into a new empty java
file in a new project. The new project and file have different names than
the original names. It runs fine with the new name - no errors. The file
name that has the problem is Nvj5.java. That is the file selected and
displayed when I click RUN FILE. It is the file listed below. Even though it
is selected and displayed when I click RUN FILE my system is running some
other huge file (with errors) instead. The errors is copied below. Has
anyone ever heard of a problem like this? Please help. I asked questions in
a Java news group but they haven'tcome up with anything yet.
TIA Bill S.
HERE'S THE ERROR OUTPUT:
run:
Exception in thread "main" java.lang.VerifyError: Constructor must call
super() or this() before return in method Nvr1.<init>()V at offset 0
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
at java.lang.Class.getMethod0(Class.java:2685)
at java.lang.Class.getMethod(Class.java:1620)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:488)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:480)
Java Result: 1
HERE'S THE JAVA FILE:
import java.io.*;
public class Nvj5 {
public static void main(String[] args){
try {
FileInputStream file = new FileInputStream("NVRAM.TXT");
char[] nvchr = new char [30000];
int fin = 1;
int count = 1;
while (fin != -1) {
fin = file.read();
nvchr[count] = (char) fin;
System.out.print(nvchr[count]);
count++;
}
System.out.println("Bytes read : " + count);
file.close();
} catch (IOException e){
System.out.println("Could not read file");
}
}
}
Reply to: