Path: csiph.com!usenet.pasdenom.info!news.albasani.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: bilsch Newsgroups: comp.lang.java.programmer Subject: Re: my java is broken ! Date: Sat, 05 May 2012 15:03:37 -0700 Organization: A noiseless patient Spider Lines: 70 Message-ID: References: <15508526.29.1336086347980.JavaMail.geo-discussion-forums@ynjj16> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 5 May 2012 22:03:39 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="llALXQ6TxsVqIoSLcrwVyA"; logging-data="709"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/+bdVo2Mr4oKjtfFFVGrMY" User-Agent: Mozilla/5.0 (X11; Linux i686; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 In-Reply-To: Cancel-Lock: sha1:fWUlDXsoTSXOrJVxs5YCFcRIHY4= Xref: csiph.com comp.lang.java.programmer:14298 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 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. > >