Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #14233
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: my java is broken ! |
| Date | 2012-05-03 16:05 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <15508526.29.1336086347980.JavaMail.geo-discussion-forums@ynjj16> (permalink) |
| References | <jnjb8s$vlu$1@dont-email.me> <jnjj1m$8iu$2@dont-email.me> <jnkett$idc$1@dont-email.me> <FPjnr.25381$Ec.348@newsfe16.iad> <jnuvbt$383$1@dont-email.me> |
bilsch wrote:
> Arved Sandstrom wrote:
>>>> bilsch wrote:
>>>>> I wrote a loop to read a 26000 character text file NVRAM.TXT into a
>>>>> character array. It worked fine. The program is listed below. It has
>>>>> only 24 lines. Today when I run it, it has weird errors referenced to
>>>>> line numbers 2442, 2685 and 1620. When I click on those error messages
>>>>> it shows lines in a completely different program - a program that I
>>>>> never wrote for sure. I saved the file with a different name and it runs
>>>>> fine with that name - no errors. The file name that has the problem is
>>>>> Nvj5. 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 instead. Has
>>>>> anyone ever heard of a problem like this?
. . .
>> Your system is not "running" some other "file", not in the sense that
>> you think. Your Java source files are compiled into .class files, these
>> are loaded up into memory as required, and broadly speaking it's the
>> bytecodes in these class files that get executed ("run"). The first
>> application code to execute is the proper main() method in your main
>> class...like Nvj5.main(). Since you are using standard library code
>> also, like FileInputStream, code in those classes - and in the classes
>> that FileInputStream uses, and so on and so on - also gets executed.
>>
. . .
> I copied the source from the offending file then I deleted the entire
> project folder - everything. Then I created a new project and a new
> blank .java file and pasted the copied source in that new file. I used
> new names for the new file and folder. Once I did that the source(in
> the new file) ran without a glitch. I tested it several times over a
> period of days and it always worked. NOW, TODAY THE NEW FILE HAS GOTTEN
> THE SAME PROBLEM JUST LIKE THE OLD FILE I have the error information
What do you mean by "FILE", exactly?
Files don't execute in Java.
> pasted below along with the source, also below. The error lines are in a
> different file than the one I am running - now named Nvr1.java..
The error message clearly states, "method Nvr1.<init>()V". That is definitely in your class. It is, in fact, the initializer of your class.
How do you conclude otherwise?
> THE ERROR INFORMATION:
> 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
> BUILD SUCCESSFUL (total time: 4 seconds)
>
>
> THE SOURCE:
> import java.io.*;
>
> public class Nvr1 {
>
> 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;
Why aren't you using the first element of the array?
> System.out.print(nvchr[count]);
> count++;
> }
What happens if 'count' equals '30000'?
> System.out.println("Bytes read : " + count);
> file.close();
> } catch (IOException e){
> System.out.println("Could not read file");
> }
>
> }
> }
The problem, based on what we've seen here, might be in the way the command is invoked. It depends on being run from the correct directory with all the right libraries in its classpath. If those conditions don't hold, you could get weird results.
That said, the error message doesn't jibe well with what we're seeing. You don't call any constructors, so it's odd the error message refers to constructors.
What happens (i.e., copy and paste the output) when you run the program from the command line?
--
Lew
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
my java is broken ! bilsch <king621@comcast.net> - 2012-04-29 05:13 -0700
Re: my java is broken ! bilsch <king621@comcast.net> - 2012-04-29 05:36 -0700
Re: my java is broken ! Roedy Green <see_website@mindprod.com.invalid> - 2012-04-29 07:05 -0700
Re: my java is broken ! Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-04-29 09:25 -0500
Re: my java is broken ! bilsch <king621@comcast.net> - 2012-04-29 15:21 -0700
Re: my java is broken ! Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-04-29 20:06 -0300
Re: my java is broken ! bilsch <king621@comcast.net> - 2012-05-03 15:03 -0700
Re: my java is broken ! Lew <lewbloch@gmail.com> - 2012-05-03 16:05 -0700
Re: my java is broken ! Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-05-03 20:44 -0300
Re: my java is broken ! bilsch <king621@comcast.net> - 2012-05-03 22:38 -0700
Re: my java is broken ! Lew <lewbloch@gmail.com> - 2012-05-04 06:43 -0700
Re: my java is broken ! Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-05-04 14:07 +0000
Re: my java is broken ! Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-05-04 09:11 -0500
Re: my java is broken ! bilsch <king621@comcast.net> - 2012-05-04 15:06 -0700
Re: my java is broken ! Martin Gregorie <martin@address-in-sig.invalid> - 2012-05-04 23:06 +0000
Re: my java is broken ! bilsch <king621@comcast.net> - 2012-05-05 15:03 -0700
Re: my java is broken ! bilsch <king621@comcast.net> - 2012-05-05 15:04 -0700
Re: my java is broken ! Lew <lewbloch@gmail.com> - 2012-05-04 17:04 -0700
Re: my java is broken ! bilsch <king621@comcast.net> - 2012-05-05 15:30 -0700
Re: my java is broken ! markspace <-@.> - 2012-05-05 15:58 -0700
Re: my java is broken ! Lew <noone@lewscanon.com> - 2012-05-05 22:37 -0700
Re: my java is broken ! Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-05-04 19:48 -0500
Re: my java is broken ! Martin Gregorie <martin@address-in-sig.invalid> - 2012-05-05 15:02 +0000
Re: my java is broken ! bilsch <king621@comcast.net> - 2012-05-05 15:26 -0700
Re: my java is broken ! Martin Gregorie <martin@address-in-sig.invalid> - 2012-05-05 22:57 +0000
Re: my java is broken ! Lew <noone@lewscanon.com> - 2012-05-05 22:41 -0700
csiph-web