Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #14017 > unrolled thread
| Started by | bilsch <king621@comcast.net> |
|---|---|
| First post | 2012-04-29 05:13 -0700 |
| Last post | 2012-05-05 22:41 -0700 |
| Articles | 20 on this page of 26 — 10 participants |
Back to article view | Back to comp.lang.java.programmer
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
Page 1 of 2 [1] 2 Next page →
| From | bilsch <king621@comcast.net> |
|---|---|
| Date | 2012-04-29 05:13 -0700 |
| Subject | my java is broken ! |
| Message-ID | <jnjb8s$vlu$1@dont-email.me> |
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?
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");
}
}
}
[toc] | [next] | [standalone]
| From | bilsch <king621@comcast.net> |
|---|---|
| Date | 2012-04-29 05:36 -0700 |
| Message-ID | <jnjckh$6kf$1@dont-email.me> |
| In reply to | #14017 |
On 04/29/2012 05:26 AM, Stefan Ram wrote: > bilsch<king621@comcast.net> writes: >> I click RUN FILE my system is running some other huge file instead. > > Possibly, an exception was thrown from the standard library and > the line number shows where in the standard library it did originate. > Do you think it could be due to a virus? I'm running Linux Ubuntu - the linux heads all say there's no anti-virus programs for linux.
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2012-04-29 07:05 -0700 |
| Message-ID | <ddiqp7hcvu9g39o4gvo6vqrd5csjod7rnt@4ax.com> |
| In reply to | #14019 |
On Sun, 29 Apr 2012 05:36:32 -0700, bilsch <king621@comcast.net> wrote, quoted or indirectly quoted someone who said : >Do you think it could be due to a virus? I'm running Linux Ubuntu - the >linux heads all say there's no anti-virus programs for linux. Viruses are blamed all the time for errors the user made and bugs in the OS. When you are programming it is nearly always your own fault. If you get a stack trace, look for the line in your own program not ones in the standard library. If you get a mysterious compiler error see http://mindprod.com/jgloss/compilererrormessages.html If you are seeking help, you need to list the program and the compiler error message and indicate where in the program each error message is pointing. Try compiling without an IDE using just JavaC in case the problem is misunderstanding how to use the IDE. see http://mindprod.com/jgloss/javacexe.html -- Roedy Green Canadian Mind Products http://mindprod.com Programmers love to create simplified replacements for HTML. They forget that the simplest language is the one you already know. They also forget that their simple little markup language will bit by bit become even more convoluted and complicated than HTML because of the unplanned way it grows. .
[toc] | [prev] | [next] | [standalone]
| From | Joshua Cranmer <Pidgeot18@verizon.invalid> |
|---|---|
| Date | 2012-04-29 09:25 -0500 |
| Message-ID | <jnjj1m$8iu$2@dont-email.me> |
| In reply to | #14017 |
On 4/29/2012 7:13 AM, 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? When you refuse to mention error messages, the answer becomes "I have no clue." It would also help to know what the command line is that is causing it. It could be that your IDE is buggy, too (since it sounds like you rely on a specific IDE feature). -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth
[toc] | [prev] | [next] | [standalone]
| From | bilsch <king621@comcast.net> |
|---|---|
| Date | 2012-04-29 15:21 -0700 |
| Message-ID | <jnkett$idc$1@dont-email.me> |
| In reply to | #14023 |
On 04/29/2012 07:25 AM, Joshua Cranmer wrote: > On 4/29/2012 7:13 AM, 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? > > When you refuse to mention error messages, the answer becomes "I have no > clue." > > It would also help to know what the command line is that is causing it. > It could be that your IDE is buggy, too (since it sounds like you rely > on a specific IDE feature). > I can't tell you the error messages now because I deleted the offending file - so can't generate errors anymore. It seems the error messages are irrelevant since they point to lines in some large unknown program.
[toc] | [prev] | [next] | [standalone]
| From | Arved Sandstrom <asandstrom3minus1@eastlink.ca> |
|---|---|
| Date | 2012-04-29 20:06 -0300 |
| Message-ID | <FPjnr.25381$Ec.348@newsfe16.iad> |
| In reply to | #14038 |
On 12-04-29 07:21 PM, bilsch wrote:
> On 04/29/2012 07:25 AM, Joshua Cranmer wrote:
>> On 4/29/2012 7:13 AM, 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?
>>
>> When you refuse to mention error messages, the answer becomes "I have no
>> clue."
>>
>> It would also help to know what the command line is that is causing it.
>> It could be that your IDE is buggy, too (since it sounds like you rely
>> on a specific IDE feature).
>>
> I can't tell you the error messages now because I deleted the offending
> file - so can't generate errors anymore. It seems the error messages
> are irrelevant since they point to lines in some large unknown program.
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.
That mysterious huge file is a standard library class that your code
needs to work. It's not irrelevant. A high percentage of the time when
you write buggy code the errors start in library code, not in your own
code. You need to look at the entire stack. You will notice that
somewhere in the stack are line references to your own code also.
You deleted and renamed *which* files exactly? Also, you have a class
Nvj5 but a corresponding source file "Nvj5.java". You'll find that
people understand you better if you differentiate between data files
(like NVRAM.TXT) and source files (like Nvj5.java).
Are you saying that you renamed class Nvj5 in source file Nvj5.java to
class Pwll12 in source file Pwll12.java, say, and ever since your
program has run like a charm? That seems highly unlikely. In fact that's
astronomically unlikely.
What IDE or programming text editor are you using? How many "main"
classes are currently available in your workspace? When you tried that
failing run did you see any console output at all?
AHS
--
A fly was very close to being called a "land," cause that's what they do
half the time.
-- Mitch Hedberg
[toc] | [prev] | [next] | [standalone]
| From | bilsch <king621@comcast.net> |
|---|---|
| Date | 2012-05-03 15:03 -0700 |
| Message-ID | <jnuvbt$383$1@dont-email.me> |
| In reply to | #14039 |
On 04/29/2012 04:06 PM, Arved Sandstrom wrote:
> On 12-04-29 07:21 PM, bilsch wrote:
>> On 04/29/2012 07:25 AM, Joshua Cranmer wrote:
>>> On 4/29/2012 7:13 AM, 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?
>>>
>>> When you refuse to mention error messages, the answer becomes "I have no
>>> clue."
>>>
>>> It would also help to know what the command line is that is causing it.
>>> It could be that your IDE is buggy, too (since it sounds like you rely
>>> on a specific IDE feature).
>>>
>> I can't tell you the error messages now because I deleted the offending
>> file - so can't generate errors anymore. It seems the error messages
>> are irrelevant since they point to lines in some large unknown program.
>
> 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.
>
> That mysterious huge file is a standard library class that your code
> needs to work. It's not irrelevant. A high percentage of the time when
> you write buggy code the errors start in library code, not in your own
> code. You need to look at the entire stack. You will notice that
> somewhere in the stack are line references to your own code also.
>
> You deleted and renamed *which* files exactly? Also, you have a class
> Nvj5 but a corresponding source file "Nvj5.java". You'll find that
> people understand you better if you differentiate between data files
> (like NVRAM.TXT) and source files (like Nvj5.java).
>
> Are you saying that you renamed class Nvj5 in source file Nvj5.java to
> class Pwll12 in source file Pwll12.java, say, and ever since your
> program has run like a charm? That seems highly unlikely. In fact that's
> astronomically unlikely.
>
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
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..
> What IDE or programming text editor are you using? How many "main"
> classes are currently available in your workspace? When you tried that
> failing run did you see any console output at all?
>
I am using NetBeans to do exerything.
> AHS
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;
System.out.print(nvchr[count]);
count++;
}
System.out.println("Bytes read : " + count);
file.close();
} catch (IOException e){
System.out.println("Could not read file");
}
}
}
TIA. Bill S.
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-05-03 16:05 -0700 |
| Message-ID | <15508526.29.1336086347980.JavaMail.geo-discussion-forums@ynjj16> |
| In reply to | #14225 |
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
[toc] | [prev] | [next] | [standalone]
| From | Arved Sandstrom <asandstrom3minus1@eastlink.ca> |
|---|---|
| Date | 2012-05-03 20:44 -0300 |
| Message-ID | <HLEor.33482$JR1.13053@newsfe06.iad> |
| In reply to | #14233 |
On 12-05-03 08:05 PM, Lew wrote: [ SNIP ] > 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. [ SNIP ] It doesn't jibe, no. OTOH, a search on the VerifyError message + "NetBeans" does turn up indications that NB exhibits this error in several situations. Often solved, just as with Eclipse in umpteen circumstances, with the classic "Clean-Rebuild-Try Again-Curse-Repeat" cycle. I wouldn't rule out that there is NetBeans badness here. I figure most of us have encountered situations where you open up an IDE on a project, where the day before everything was OK, and now suddenly it's seriously out of whack. Your suggestion to have the OP try the build and run on the command line is a great idea. I strongly second that. AHS -- A fly was very close to being called a "land," cause that's what they do half the time. -- Mitch Hedberg
[toc] | [prev] | [next] | [standalone]
| From | bilsch <king621@comcast.net> |
|---|---|
| Date | 2012-05-03 22:38 -0700 |
| Message-ID | <jnvpvs$1bo$1@dont-email.me> |
| In reply to | #14234 |
On 05/03/2012 04:44 PM, Arved Sandstrom wrote: > On 12-05-03 08:05 PM, Lew wrote: > [ SNIP ] > >> 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. > [ SNIP ] > > It doesn't jibe, no. OTOH, a search on the VerifyError message + > "NetBeans" does turn up indications that NB exhibits this error in > several situations. Often solved, just as with Eclipse in umpteen > circumstances, with the classic "Clean-Rebuild-Try Again-Curse-Repeat" > cycle. > > I wouldn't rule out that there is NetBeans badness here. I figure most > of us have encountered situations where you open up an IDE on a project, > where the day before everything was OK, and now suddenly it's seriously > out of whack. > > Your suggestion to have the OP try the build and run on the command line > is a great idea. I strongly second that. > > AHS Programs java and javac are in directory: /home/bilsch/jdk7/bin/ Offending program, Nvr1.java is in directory: /home/bilsch/NetBeansProjects/NVRAM/src/ environment variable PATH is: /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games However note that when I run; java Nvr1.class (or simply Nvr1) from my home directory the output errors are in javanese, as follows: bilsch@p4pwj:~/jdk7/bin$ java Nvr1 Exception in thread "main" java.lang.NoClassDefFoundError: Nvr1 Caused by: java.lang.ClassNotFoundException: Nvr1 at java.net.URLClassLoader$1.run(URLClassLoader.java:217) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266) Could not find the main class: Nvr1. Program will exit. bilsch@p4pwj:~/jdk7/bin$ cd bilsch@p4pwj:~$ java Nvr1.class Exception in thread "main" java.lang.NoClassDefFoundError: Nvr1/class Caused by: java.lang.ClassNotFoundException: Nvr1.class at java.net.URLClassLoader$1.run(URLClassLoader.java:217) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266) Could not find the main class: Nvr1.class. Program will exit. Therefore the command line is hooked up with the java directory - regardless of the PATH. When I change working directory to /home/bilsch/jdk7/bin/ and type in the path and filename for the offending file I get the following output: bilsch@p4pwj:~/jdk7/bin$ javac /NetBeansProjects/NVRAM/src/Nvr1 The program 'javac' can be found in the following packages: * openjdk-6-jdk * ecj * gcj-4.4-jdk * gcj-4.6-jdk * gcj-4.5-jdk * openjdk-7-jdk Try: sudo apt-get install <selected package> bilsch@p4pwj:~/jdk7/bin$ bilsch@p4pwj:~/jdk7/bin$ Ubuntu can't find javac even though I ran it from the directory where javac resides. It can't find it from the home directory either. THE SHORT ANSWER IS I CAN'T COMPILE OR RUN JAVA FROM MY LINUX COMMAND LINE. I can't answer your question of what the output is when running command line. Also I have no idea why Linux won't do it. I'LL HAVE TO WORK ON THAT. I have to figure how to run from command line in linux. If I could run using Windows command line and it worked that would be inconclusive ie. taking Linux out of the equation. If I could run it in Windows command line tonight and it worked OK that wouldn't mean it would still work 4 days from now? This could be a Linux glitch rather than Java. Thanks for listening. Bill S.
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-05-04 06:43 -0700 |
| Message-ID | <13372351.454.1336139019705.JavaMail.geo-discussion-forums@pbew9> |
| In reply to | #14249 |
bilsch wrote:
> Programs java and javac are in directory: /home/bilsch/jdk7/bin/
> Offending program, Nvr1.java is in directory:
>
> /home/bilsch/NetBeansProjects/NVRAM/src/
>
> environment variable PATH is:
>
> /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
>
> However note that when I run; java Nvr1.class (or simply Nvr1) from my
> home directory the output errors are in javanese, as follows:
>
> bilsch@p4pwj:~/jdk7/bin$ java Nvr1
> Exception in thread "main" java.lang.NoClassDefFoundError: Nvr1
> Caused by: java.lang.ClassNotFoundException: Nvr1
> at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
> Could not find the main class: Nvr1. Program will exit.
> bilsch@p4pwj:~/jdk7/bin$ cd
> bilsch@p4pwj:~$ java Nvr1.class
> Exception in thread "main" java.lang.NoClassDefFoundError: Nvr1/class
> Caused by: java.lang.ClassNotFoundException: Nvr1.class
> at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
>
> Could not find the main class: Nvr1.class. Program will exit.
>
> Therefore the command line is hooked up with the java directory -
> regardless of the PATH.
Huh?
Besides that I'm not sure what you mean by "the command line is hooked up with the java directory", there is no reason to associate the PATH envar with the error you show, which is simply due to the fact that you did not specify the classpath correctly. Or at all. And tried to run the Java program from a directory such that the default classpath does not include it.
> When I change working directory to /home/bilsch/jdk7/bin/ and type in
> the path and filename for the offending file I get the following output:
>
> bilsch@p4pwj:~/jdk7/bin$ javac /NetBeansProjects/NVRAM/src/Nvr1
>
> The program 'javac' can be found in the following packages:
> * openjdk-6-jdk
> * ecj
> * gcj-4.4-jdk
> * gcj-4.6-jdk
> * gcj-4.5-jdk
> * openjdk-7-jdk
> Try: sudo apt-get install <selected package>
> bilsch@p4pwj:~/jdk7/bin$
> bilsch@p4pwj:~/jdk7/bin$
>
> Ubuntu can't find javac even though I ran it from the directory where
> javac resides. It can't find it from the home directory either.
>
> THE SHORT ANSWER IS I CAN'T COMPILE OR RUN JAVA FROM MY LINUX COMMAND
> LINE. I can't answer your question of what the output is when running
Shh.
> command line. Also I have no idea why Linux won't do it. I'LL HAVE TO
> WORK ON THAT.
Shh.
You showed us the output. Why do you say you can't answer the question that you just answered?
> I have to figure how to run from command line in linux. If I could run
You could try reading the documentation for the "java" command.
Try this:
$ java -cp ${directory_where_the_class_file_is} Nvr1
> using Windows command line and it worked that would be inconclusive ie.
> taking Linux out of the equation. If I could run it in Windows command
> line tonight and it worked OK that wouldn't mean it would still work 4
> days from now?
If you were to specify the command line correctly, it would work right now, in Linux.
> This could be a Linux glitch rather than Java.
No, it's operator error.
Neither Linux nor Java is at fault.
You need to read the documentation for the commands you're using, is all.
Had you done so, you'd've known up front that "java Nvr1.class" is wrong always, and why your attempt to run "java Nvr1" without a matching classpath failed.
Which it would do in the same way in Windows for the same reason.
RTFM.
--
Lew
[toc] | [prev] | [next] | [standalone]
| From | Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> |
|---|---|
| Date | 2012-05-04 14:07 +0000 |
| Message-ID | <slrnjq7okh.kvi.avl@gamma.logic.tuwien.ac.at> |
| In reply to | #14249 |
bilsch <king621@comcast.net> wrote: > environment variable PATH is: > /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games > bilsch@p4pwj:~/jdk7/bin$ java Nvr1 You don't have "." or ~/jdk7/bin in your PATH. So it probably has picked up some system-installed java from /usr/bin Add the bin directory of your jdk7 to the beginning of your PATH, and some of your obstacles might dissolve. Anyway, your Nvr1.class file surely isn't in ~/jdk7/bin, so the > Could not find the main class: Nvr1. Program will exit. was to be expected. > bilsch@p4pwj:~/jdk7/bin$ javac /NetBeansProjects/NVRAM/src/Nvr1 > The program 'javac' can be found in the following packages: That's a shell-convenience, and it seems like you have a jre installed system-wide, but not a jdk. To actually use your priovate jdk7 installation, you have to add it to your PATH (and before /usr/bin) Your PATH probably should look like: /home/bilsch/jdk7/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games (I'm speculating about your actual home-directory here)
[toc] | [prev] | [next] | [standalone]
| From | Leif Roar Moldskred <leifm@dimnakorr.com> |
|---|---|
| Date | 2012-05-04 09:11 -0500 |
| Message-ID | <TrmdnTWNrM06fj7SnZ2dnUVZ8nCdnZ2d@giganews.com> |
| In reply to | #14249 |
bilsch <king621@comcast.net> wrote: > > Programs java and javac are in directory: /home/bilsch/jdk7/bin/ > Offending program, Nvr1.java is in directory: > > /home/bilsch/NetBeansProjects/NVRAM/src/ > > environment variable PATH is: > > /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games And there's your problem -- your PATH does not contain the directory your java and javac commands are found in, neither as an explicit entry of /home/bilsch/jdk7/bin/ or implicitly through the current directory . > However note that when I run; java Nvr1.class (or simply Nvr1) from my > home directory the output errors are in javanese, as follows: > > bilsch@p4pwj:~/jdk7/bin$ java Nvr1 > Exception in thread "main" java.lang.NoClassDefFoundError: Nvr1 > Caused by: java.lang.ClassNotFoundException: Nvr1 You're running a java command here, but not the one at /home/bilsch/jdk7/bin/java -- you must have another java command in your system somewhere. (Try the command "which java" to show where the java command that's actually being run is.) The solution is to add the directory /home/bilsch/jdk7/bin/ to the front of your PATH. Write the following command on the command line: export PATH=/home/bilsch/jdk7/bin/:$PATH You should then be able to call javac, use that to create a .class file and then use java to run the class file. -- Leif Roar Moldskred
[toc] | [prev] | [next] | [standalone]
| From | bilsch <king621@comcast.net> |
|---|---|
| Date | 2012-05-04 15:06 -0700 |
| Message-ID | <jo1jtl$i5j$1@dont-email.me> |
| In reply to | #14262 |
On 05/04/2012 07:11 AM, Leif Roar Moldskred wrote: > bilsch<king621@comcast.net> wrote: > >> >> Programs java and javac are in directory: /home/bilsch/jdk7/bin/ >> Offending program, Nvr1.java is in directory: >> >> /home/bilsch/NetBeansProjects/NVRAM/src/ >> >> environment variable PATH is: >> >> /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games > > And there's your problem -- your PATH does not contain the directory > your java and javac commands are found in, neither as an explicit > entry of /home/bilsch/jdk7/bin/ or implicitly through the current > directory . > >> However note that when I run; java Nvr1.class (or simply Nvr1) from my >> home directory the output errors are in javanese, as follows: >> >> bilsch@p4pwj:~/jdk7/bin$ java Nvr1 >> Exception in thread "main" java.lang.NoClassDefFoundError: Nvr1 >> Caused by: java.lang.ClassNotFoundException: Nvr1 > > You're running a java command here, but not the one at > /home/bilsch/jdk7/bin/java -- you must have another java command in > your system somewhere. (Try the command "which java" to show where > the java command that's actually being run is.) > > The solution is to add the directory /home/bilsch/jdk7/bin/ to the > front of your PATH. Write the following command on the command line: > > export PATH=/home/bilsch/jdk7/bin/:$PATH > > You should then be able to call javac, use that to create a .class > file and then use java to run the class file. > I added /home/bilsch/jdk7/bin to PATH and was able to both compile and run program Nvr1 from the command line. Also, when I then go into NetBeans and run the file it works without errors. HOWEVER, AFTER I RUN IN NETBEANS MY PATH STATEMENT REVERTS TO THE ORIGINAL VERSION ie. the /home/bilsch/jdk7/bin part has been removed. I even put the PATH change in two different places in the PATH variable and both were removed. Does anybody have a java IDE other than NetBeans ? Also, a pain in the ass is I must change directory to where the source file resides to compile. I must change directory to where the .class file resides in order to run. These directories are different for every project therefore it's not practical to automate with a script. Bill S.
[toc] | [prev] | [next] | [standalone]
| From | Martin Gregorie <martin@address-in-sig.invalid> |
|---|---|
| Date | 2012-05-04 23:06 +0000 |
| Message-ID | <jo1ndu$ra8$1@localhost.localdomain> |
| In reply to | #14271 |
On Fri, 04 May 2012 15:06:43 -0700, bilsch wrote: > On 05/04/2012 07:11 AM, Leif Roar Moldskred wrote: >> bilsch<king621@comcast.net> wrote: >> >> >>> Programs java and javac are in directory: /home/bilsch/jdk7/bin/ >>> Offending program, Nvr1.java is in directory: >>> >>> /home/bilsch/NetBeansProjects/NVRAM/src/ >>> >>> environment variable PATH is: >>> >>> /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/ usr/bin:/sbin:/bin:/usr/games >> >> And there's your problem -- your PATH does not contain the directory >> your java and javac commands are found in, neither as an explicit entry >> of /home/bilsch/jdk7/bin/ or implicitly through the current directory . >> >>> However note that when I run; java Nvr1.class (or simply Nvr1) from my >>> home directory the output errors are in javanese, as follows: >>> >>> bilsch@p4pwj:~/jdk7/bin$ java Nvr1 Exception in thread "main" >>> java.lang.NoClassDefFoundError: Nvr1 Caused by: >>> java.lang.ClassNotFoundException: Nvr1 >> >> You're running a java command here, but not the one at >> /home/bilsch/jdk7/bin/java -- you must have another java command in >> your system somewhere. (Try the command "which java" to show where the >> java command that's actually being run is.) >> >> The solution is to add the directory /home/bilsch/jdk7/bin/ to the >> front of your PATH. Write the following command on the command line: >> >> export PATH=/home/bilsch/jdk7/bin/:$PATH >> >> You should then be able to call javac, use that to create a .class file >> and then use java to run the class file. >> >> > I added /home/bilsch/jdk7/bin to PATH and was able to both compile and > run program Nvr1 from the command line. Also, when I then go into > NetBeans and run the file it works without errors. HOWEVER, AFTER I RUN > IN NETBEANS MY PATH STATEMENT REVERTS TO THE ORIGINAL VERSION ie. the > /home/bilsch/jdk7/bin part has been removed. I even put the PATH change > in two different places in the PATH variable and both were removed. Does > anybody have a java IDE other than NetBeans ? > Look at where PATH is defined in the NetBeans configuration and change that. > Also, a pain in the ass is I must change directory to where the source > file resides to compile. I must change directory to where the .class > file resides in order to run. These directories are different for every > project therefore it's not practical to automate with a script. > Either use Ant (write a build.xml file if you can't use the one that NetBeans uses) and/or write a shell script to run the compile from the correct directory. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |
[toc] | [prev] | [next] | [standalone]
| From | bilsch <king621@comcast.net> |
|---|---|
| Date | 2012-05-05 15:03 -0700 |
| Message-ID | <jo483r$m5$1@dont-email.me> |
| In reply to | #14272 |
On 05/04/2012 04:06 PM, Martin Gregorie wrote: > On Fri, 04 May 2012 15:06:43 -0700, bilsch wrote: > >> On 05/04/2012 07:11 AM, Leif Roar Moldskred wrote: >>> bilsch<king621@comcast.net> wrote: >>> >>> >>>> Programs java and javac are in directory: /home/bilsch/jdk7/bin/ >>>> Offending program, Nvr1.java is in directory: >>>> >>>> /home/bilsch/NetBeansProjects/NVRAM/src/ >>>> >>>> environment variable PATH is: >>>> >>>> /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/ > usr/bin:/sbin:/bin:/usr/games >>> >>> And there's your problem -- your PATH does not contain the directory >>> your java and javac commands are found in, neither as an explicit entry >>> of /home/bilsch/jdk7/bin/ or implicitly through the current directory . >>> >>>> However note that when I run; java Nvr1.class (or simply Nvr1) from my >>>> home directory the output errors are in javanese, as follows: >>>> >>>> bilsch@p4pwj:~/jdk7/bin$ java Nvr1 Exception in thread "main" >>>> java.lang.NoClassDefFoundError: Nvr1 Caused by: >>>> java.lang.ClassNotFoundException: Nvr1 >>> >>> You're running a java command here, but not the one at >>> /home/bilsch/jdk7/bin/java -- you must have another java command in >>> your system somewhere. (Try the command "which java" to show where the >>> java command that's actually being run is.) >>> >>> The solution is to add the directory /home/bilsch/jdk7/bin/ to the >>> front of your PATH. Write the following command on the command line: >>> >>> export PATH=/home/bilsch/jdk7/bin/:$PATH >>> >>> You should then be able to call javac, use that to create a .class file >>> and then use java to run the class file. >>> >>> >> I added /home/bilsch/jdk7/bin to PATH and was able to both compile and >> run program Nvr1 from the command line. Also, when I then go into >> NetBeans and run the file it works without errors. HOWEVER, AFTER I RUN >> IN NETBEANS MY PATH STATEMENT REVERTS TO THE ORIGINAL VERSION ie. the >> /home/bilsch/jdk7/bin part has been removed. I even put the PATH change >> in two different places in the PATH variable and both were removed. Does >> anybody have a java IDE other than NetBeans ? >> > Look at where PATH is defined in the NetBeans configuration and change > that. I can't find any place where path is defined in NetBeans. They told me two ways to change PATH outside of NetBeans. I did that. > >> Also, a pain in the ass is I must change directory to where the source >> file resides to compile. I must change directory to where the .class >> file resides in order to run. These directories are different for every >> project therefore it's not practical to automate with a script. >> > Either use Ant (write a build.xml file if you can't use the one that > NetBeans uses) and/or write a shell script to run the compile from the > correct directory. I have an ANT directory and a tab for it in NetBeans but I dont know if it is installed. Same goes for Maven. I tried starting it on the command line ant there it says to install it. > >
[toc] | [prev] | [next] | [standalone]
| From | bilsch <king621@comcast.net> |
|---|---|
| Date | 2012-05-05 15:04 -0700 |
| Message-ID | <jo485q$m5$2@dont-email.me> |
| In reply to | #14272 |
On 05/04/2012 04:06 PM, Martin Gregorie wrote: > On Fri, 04 May 2012 15:06:43 -0700, bilsch wrote: > >> On 05/04/2012 07:11 AM, Leif Roar Moldskred wrote: >>> bilsch<king621@comcast.net> wrote: >>> >>> >>>> Programs java and javac are in directory: /home/bilsch/jdk7/bin/ >>>> Offending program, Nvr1.java is in directory: >>>> >>>> /home/bilsch/NetBeansProjects/NVRAM/src/ >>>> >>>> environment variable PATH is: >>>> >>>> /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/ > usr/bin:/sbin:/bin:/usr/games >>> >>> And there's your problem -- your PATH does not contain the directory >>> your java and javac commands are found in, neither as an explicit entry >>> of /home/bilsch/jdk7/bin/ or implicitly through the current directory . >>> >>>> However note that when I run; java Nvr1.class (or simply Nvr1) from my >>>> home directory the output errors are in javanese, as follows: >>>> >>>> bilsch@p4pwj:~/jdk7/bin$ java Nvr1 Exception in thread "main" >>>> java.lang.NoClassDefFoundError: Nvr1 Caused by: >>>> java.lang.ClassNotFoundException: Nvr1 >>> >>> You're running a java command here, but not the one at >>> /home/bilsch/jdk7/bin/java -- you must have another java command in >>> your system somewhere. (Try the command "which java" to show where the >>> java command that's actually being run is.) >>> >>> The solution is to add the directory /home/bilsch/jdk7/bin/ to the >>> front of your PATH. Write the following command on the command line: >>> >>> export PATH=/home/bilsch/jdk7/bin/:$PATH >>> >>> You should then be able to call javac, use that to create a .class file >>> and then use java to run the class file. >>> >>> >> I added /home/bilsch/jdk7/bin to PATH and was able to both compile and >> run program Nvr1 from the command line. Also, when I then go into >> NetBeans and run the file it works without errors. HOWEVER, AFTER I RUN >> IN NETBEANS MY PATH STATEMENT REVERTS TO THE ORIGINAL VERSION ie. the >> /home/bilsch/jdk7/bin part has been removed. I even put the PATH change >> in two different places in the PATH variable and both were removed. Does >> anybody have a java IDE other than NetBeans ? >> > Look at where PATH is defined in the NetBeans configuration and change > that. > >> Also, a pain in the ass is I must change directory to where the source >> file resides to compile. I must change directory to where the .class >> file resides in order to run. These directories are different for every >> project therefore it's not practical to automate with a script. >> > Either use Ant (write a build.xml file if you can't use the one that > NetBeans uses) and/or write a shell script to run the compile from the > correct directory. > > I'm not too handy with shell programming.
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-05-04 17:04 -0700 |
| Message-ID | <12032768.867.1336176279160.JavaMail.geo-discussion-forums@pbyy9> |
| In reply to | #14271 |
bilsch wrote:
> Also, a pain in the ass is I must change directory to where the source
> file resides to compile. I must change directory to where the .class
> file resides in order to run. These directories are different for every
> project therefore it's not practical to automate with a script.
That is totally untrue.
Both the compiler ("javac") and the runtime ("java") respect classpaths,
and the latter respects source paths. With those, you can compile and run
Java code from any directory regardless of your current directory.
Please, please, please, please, *please* RTFM!
Especially before you start ranting incorrectly about what is not possible.
Why did you ignore the earlier advice to do that?
--
Lew
[toc] | [prev] | [next] | [standalone]
| From | bilsch <king621@comcast.net> |
|---|---|
| Date | 2012-05-05 15:30 -0700 |
| Message-ID | <jo49n3$7vk$2@dont-email.me> |
| In reply to | #14275 |
On 05/04/2012 05:04 PM, Lew wrote:
> bilsch wrote:
>> Also, a pain in the ass is I must change directory to where the source
>> file resides to compile. I must change directory to where the .class
>> file resides in order to run. These directories are different for every
>> project therefore it's not practical to automate with a script.
>
> That is totally untrue.
>
> Both the compiler ("javac") and the runtime ("java") respect classpaths,
> and the latter respects source paths. With those, you can compile and run
> Java code from any directory regardless of your current directory.
Would you care to elaborate on this or give me a link where I can read
about it?
>
> Please, please, please, please, *please* RTFM!
I don't have the FM
>
> Especially before you start ranting incorrectly about what is not possible.
>
> Why did you ignore the earlier advice to do that?
>
[toc] | [prev] | [next] | [standalone]
| From | markspace <-@.> |
|---|---|
| Date | 2012-05-05 15:58 -0700 |
| Message-ID | <jo4bbl$gt8$1@dont-email.me> |
| In reply to | #14302 |
On 5/5/2012 3:30 PM, bilsch wrote:
> On 05/04/2012 05:04 PM, Lew wrote:
>> Both the compiler ("javac") and the runtime ("java") respect classpaths,
>>...
> Would you care to elaborate on this or give me a link where I can read
> about it?
...
>
> I don't have the FM
There's an old FAQ floating about the web titled "How to Ask Smart
Questions" or something like that. It also has some standard answers,
like STFW or "search the f'ing web." It's a standard answer because it
works. I typed "javac" into Google and the first thing it should me was
an Oracle page on how to use javac. It was and old 1.4 page, so I
searched for "javac 6" and got the most recent page.
P.S. Found it:
<http://www.catb.org/~esr/faqs/smart-questions.html>
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.java.programmer
csiph-web