[Geany] Not able to run .class files ( Java) in geany

Barry van Oudtshoorn bvanoudtshoorn at xxxxx
Mon Nov 9 06:23:54 UTC 2009


This isn't actually a problem in Geany so much as it is a 
misunderstanding about how Java packages work.

Check out this resource for help: 
http://java.sun.com/docs/books/tutorial/java/package/packages.html

On 09/11/09 11:44, R.Siddharth wrote:
> I facing some problems in running java.class files from geany, I am able
> to successfully compile the the java source files .
>
> Here is a simple example of what is happening :
> I have a Source file named VowelsToUnderScores.java which resides under
> the package(directory) called 'strings' . I have set the classpath for
> both the Compilation and Execution in "Set Includes and Arguments"
> dialog box and the commands in the dialog box goes like this:
> -------------------------
> Java source file commands
>
> Compile : javac -classpath /home/siddharth/Programming/Java\
> Files/oprt/opr/src "%f"
>
> Execute : java -classpath /home/siddharth/Programming/Java\
> Files/oprt/opr/src "%e"
>
> ----------------------
>
> As I said the compilation was successful but when I run the compiled
> file (F5) , I get get an error in the Run Window which shows the
> following error messages :
>
> ----------------------------------
> Exception in thread "main" java.lang.NoClassDefFoundError:
> VowelsToUnderScores
> Caused by: java.lang.ClassNotFoundException: VowelsToUnderScores
>          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:323)
>          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
>          at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
>          at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
> Could not find the main class: VowelsToUnderScores. Program will exit.
> ----------------------------------------------
>
> Here is the code written in VowelsToUnderScores.java file for your
> reference :
> -------------------------------------------------
> /*
>   *      VowelsToUnderScores.java
>   *
>   *      Copyright 2009 R.Siddharth
>   *
>   *      This program is free software; you can redistribute it and/or
> *modify
>   *      it under the terms of the GNU General Public License as
> *published by
>   *      the Free Software Foundation; either version 2 of the License,
> *or
>   *      (at your option) any later version.
>   *
>   *      This program is distributed in the hope that it will be useful,
>   *      but WITHOUT ANY WARRANTY; without even the implied warranty of
>   *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>   *      GNU General Public License for more details.
>   *
>   *      You should have received a copy of the GNU General Public
> *License
>   *      along with this program; if not, write to the Free Software
>   *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
>   *      MA 02110-1301, USA.
>   */
> package strings;
> import java.util.regex.*;
> public class VowelsToUnderScores {
>      private String s ;
>      private Pattern p;
>      private Matcher m;
>      private boolean b;
>      public VowelsToUnderScores(String a) {
>          this.s = a ;
>          p = Pattern.compile("[a,e,i,o,u,A,E,I,O,U]");
>      }
>
>      public void vwlsto_() {
>          m = p.matcher(this.s);
>          String rs ;
>          rs = m.replaceAll("_");
>          System.out.println(rs);
>      }
> 	public static void main (String args[]) {		
> 		VowelsToUnderScores vtu = new VowelsToUnderScores("I am using
> GNU/Linux Operating system.");
> 		vtu.vwlsto_();
> 	}
> }
> -----------------------------------------------------------------
> Here's another bit of information which I accidentally found when
> writing this mail - when I comment the package information and make the
> Execute command in the Set Includes and Argument dialog look like this :
>
> --------
> Execute : java "%e"
> ----------
> Then I am able to run the program successfully ! .
>
>
> I want to be able to run the code with the package information intact .
> Can any one here help me out ? .
>
> Thank you for your help .
>    


-- 
Not sent from my iPhone.




More information about the Users mailing list