Results 1 to 3 of 3
  1. #1
    Hiro ZA's Avatar
    Hiro ZA is offline Member
    Join Date
    Jan 2008
    Location
    South Africa
    Posts
    8
    Rep Power
    0

    Default Package/Execution woes [SOLVED]

    Hello people

    I am certain this is a very simple problem to solve, but alas, my lack of experience renders me helpless.

    here is the scene :

    I have created a library, with a package, and a class within this package which connects to our oracle DB. the package name is avon and the class within this this package is called ConnectDB.

    I then have a program called DBHealth which is stored in a package AvonApps and this DBHealth class makes a call to the avon.ConnectDB class.

    the program runs perfectly in NetBeans and it is able to connect to the DB and run a simple health check to pickup invalid DB objects.

    but when I try to run it from DOS as a batch executable file, I get the following error :

    C:\Java>java -cp c:\Java\Projects\MyApp\build\classes\AvonApps DBHealth

    Exception in thread "main" java.lang.NoClassDefFoundError: DBHealth (wrong name:
    AvonApps/DBHealth)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknow n Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)


    So then I tried the following execution :
    java -cp c:\Java\Projects\MyApp\build\classes AvonApps.DBHealth

    and now I get this error message :

    Exception in thread "main" java.lang.NoClassDefFoundError: avon/ConnectDB
    at AvonApps.DBHealth.<clinit>(DBHealth.java:17)


    so now it seems to have issues with the package pathing of my subclass

    how should I be executing the DBHealth class ??
    Last edited by Hiro ZA; 01-09-2008 at 07:44 AM.

  2. #2
    Hiro ZA's Avatar
    Hiro ZA is offline Member
    Join Date
    Jan 2008
    Location
    South Africa
    Posts
    8
    Rep Power
    0

    Default

    somebody? anybody? advice please ?

  3. #3
    Hiro ZA's Avatar
    Hiro ZA is offline Member
    Join Date
    Jan 2008
    Location
    South Africa
    Posts
    8
    Rep Power
    0

    Default

    haha! no worries, I figured it out :-)

    i had to set the classpath and ensure the downline folders matched package names

Similar Threads

  1. What is the execution path of wait() and notify() ?
    By AegisCruiser in forum Threads and Synchronization
    Replies: 1
    Last Post: 04-23-2008, 06:16 PM
  2. Method execution time
    By javaplus in forum Advanced Java
    Replies: 3
    Last Post: 11-26-2007, 09:51 AM
  3. Execution methods Reflection
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-15-2007, 03:19 PM
  4. Execution cut
    By Eric in forum Advanced Java
    Replies: 1
    Last Post: 06-27-2007, 03:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •