Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #14258

Re: my java is broken !

From Lew <lewbloch@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: my java is broken !
Date 2012-05-04 06:43 -0700
Organization http://groups.google.com
Message-ID <13372351.454.1336139019705.JavaMail.geo-discussion-forums@pbew9> (permalink)
References (3 earlier) <FPjnr.25381$Ec.348@newsfe16.iad> <jnuvbt$383$1@dont-email.me> <15508526.29.1336086347980.JavaMail.geo-discussion-forums@ynjj16> <HLEor.33482$JR1.13053@newsfe06.iad> <jnvpvs$1bo$1@dont-email.me>

Show all headers | View raw


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

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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