classpath problem in my machine

Discussion in 'Java' started by harryos, Dec 9, 2008.

  1. harryos

    harryos Guest

    hi
    I have an application that uses some classes in jai which i have kept
    in a lib directory.I used this build script to compile and run the
    application

    <property name="main-class" value="mypack.MyApp"/>
    <path id="myclasspath">
    <fileset dir="lib" includes="**/*.jar"/>
    </path>
    <path id="application" location="${dist.dir}/myapp.jar"/>

    <target name="compile" depends="init">
    <javac srcdir="src" destdir="${classes.dir}"
    classpathref="myclasspath"/>
    </target>

    <target name="run" depends="jar">
    <java fork="true" classname="${main-class}">
    <classpath>
    <path refid="myclasspath"/>
    <path refid="application"/>
    </classpath>
    </java>
    </target>
    ....

    when i run ant ,the compile is done without any error.But the run
    target causes an error>>
    [java] Exception in thread "main" java.lang.NoClassDefFoundError:
    javax/media/jai/OperationRegistrySpi

    The OperationRegistrySpi.class is present in javax/media/jai in
    jai_core.jar in my lib directory.

    I am working on a WinXP machine and don't have a CLASSPATH variable in
    env variables.All classpath info is supposed to be given in the ant
    script.

    I moved this application to a fresh machine where jdk and ant are
    installed and ran the script.There, my application is running without
    any error!!

    Can someone help me find out why this is happening in my machine?I
    have NetBeans and JEE5 installed in my machine .Is that any reason for
    this classpath problem?

    thanks
    harry
     
    harryos, Dec 9, 2008
    #1
    1. Advertising

  2. harryos

    Jan Thomä Guest

    On 2008-12-09 08:09:15 +0100, harryos <> said:

    > when i run ant ,the compile is done without any error.But the run
    > target causes an error>>
    > [java] Exception in thread "main" java.lang.NoClassDefFoundError:
    > javax/media/jai/OperationRegistrySpi
    >
    > I moved this application to a fresh machine where jdk and ant are
    > installed and ran the script.There, my application is running without
    > any error!!


    I wonder if you might have some spaces in the path names where you run
    your application (like C:\documents and settings\). This caused some
    weird problems here a while ago, so you might want to check that. Have
    you put the app into the same folder on both machines?

    Best regards,
    Jan
     
    Jan Thomä, Dec 9, 2008
    #2
    1. Advertising

  3. harryos

    harryos Guest

    On Dec 9, 4:15 pm, Jan Thomä <> wrote:
    > I wonder if you might have some spaces in the path names where you run your application (like C:\documents and settings\).


    No spaces are present in any of the paths..
    Also ,I used the -v option to print the classpath when java.exe is
    run.When i copy that classpath and use it to run the application from
    cmd prompt(like java -classpath ...) it runs without any problems.I
    can't figure out why ant behaves like this in one machine alone.

    thanks
    harry
     
    harryos, Dec 9, 2008
    #3
  4. harryos

    Lew Guest

    harryos wrote:
    > <property name="main-class" value="mypack.MyApp"/>
    > <path id="myclasspath">
    > <fileset dir="lib" includes="**/*.jar"/>
    > </path>
    > <path id="application" location="${dist.dir}/myapp.jar"/>

    ....
    > <target name="run" depends="jar">
    > <java fork="true" classname="${main-class}">
    > <classpath>
    > <path refid="myclasspath"/>
    > <path refid="application"/>
    > </classpath>
    > </java>
    > </target>
    > ...
    >
    > when i [sic] run ant ,the compile is done without any error.But the run
    > target causes an error>>
    > [java] Exception in thread "main" java.lang.NoClassDefFoundError:
    > javax/media/jai/OperationRegistrySpi
    >
    > The OperationRegistrySpi.class is present in javax/media/jai in
    > jai_core.jar in my lib directory.
    >
    > I am working on a WinXP machine and don't have a CLASSPATH variable in
    > env variables.All classpath info is supposed to be given in the ant
    > script.
    >
    > I moved this application to a fresh machine where jdk and ant are
    > installed and ran the script.There, my application is running without
    > any error!!
    >
    > Can someone help me find out why this is happening in my machine?I
    > have NetBeans and JEE5 installed in my machine .Is that any reason for
    > this classpath problem?


    Could it be that it's because running a program from a JAR ignores the outer
    world's classpath, and uses only the classpath from its own manifest?

    Could it be that the Ant classpath target specifies 'lib/' as a relative
    directory, which is absent in the runtime environment?

    Some of the subtleties of Ant escape me, so I'm not sure which might apply.
    However, given that part of the purpose of a JAR is to run independently of
    Ant, you need to ensure that the JAR manifest correctly specifies the path and
    that the lib/ directory (or whatever the manifest specifies) is present in the
    correction location relative to the JAR.

    --
    Lew
     
    Lew, Dec 9, 2008
    #4
  5. In article
    <>,
    harryos <> wrote:

    > On Dec 9, 4:15 pm, Jan Thomä <> wrote:
    > > I wonder if you might have some spaces in the path names where you
    > > run your application (like C:\documents and settings\).

    >
    > No spaces are present in any of the paths. Also, I used the -v option
    > to print the classpath when java.exe is run. When copy that
    > classpath and use it to run the application from cmd prompt (like
    > java -classpath ...) it runs without any problems. I can't figure
    > out why ant behaves like this in one machine alone.


    In addition to the questions Lew and Jan posed, you might also look for
    spurious additions to any of the directories listed in the system
    properties java.endorsed.dirs and java.ext.dirs.

    --
    John B. Matthews
    trashgod at gmail dot com
    http://home.roadrunner.com/~jbmatthews/
     
    John B. Matthews, Dec 9, 2008
    #5
  6. harryos

    harryos Guest

    On Dec 9, 9:23 pm, "John B. Matthews" <> wrote:
    > In addition to the questions Lew and Jan posed, you might also look for spurious additions to any of the directories listed in the system
    > properties java.endorsed.dirs and java.ext.dirs.



    hi John,
    I ran a program to print the system properties in my machine
    ..I found these problems when I checked the directories in Windows
    Explorer.

    code shows
    java.endorsed.dirs=E:\Java\jre1.6.0_05\lib\endorsed

    But in Windows Explorer, there is no folder named 'endorsed' within E:
    \Java\jre1.6.0_05\lib

    code shows
    java.ext.dirs=E:\Java\jre1.6.0_05\lib\ext;C:\WINDOWS\Sun\Java\lib\ext

    But in Windows Explorer there is no lib\ext within C:\WINDOWS\Sun
    \Java .There is only a folder named 'Deployment' (probably from jee5
    installation)

    Then again,these 2 problems are present in another machine where I did
    a fresh installation of JDK and ant.In that machine however,the run
    target I mentioned runs without any errors.

    I am really confused by this.As a last attempt, I renamed all 'lib'
    directories in my application to 'mylib' and made appropriate changes
    in the build.xml.Still,the problem persists.

    thanks for the replies,
    harry
     
    harryos, Dec 9, 2008
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UmVzaG1hIFByYWJodQ==?=

    Auto-attach to process '[1084] aspnet_wp.exe' on machine <Machine

    =?Utf-8?B?UmVzaG1hIFByYWJodQ==?=, Jan 21, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,060
    =?Utf-8?B?UmVzaG1hIFByYWJodQ==?=
    Jan 21, 2005
  2. Flip
    Replies:
    3
    Views:
    7,279
    Tony Morris
    Feb 9, 2004
  3. Gabe
    Replies:
    3
    Views:
    1,078
  4. Replies:
    2
    Views:
    755
  5. Replies:
    2
    Views:
    1,112
    Mike Schilling
    Mar 2, 2008
Loading...

Share This Page