executing my application outside the IDE does not work

Discussion in 'Java' started by marcussilfver@gmail.com, Mar 26, 2008.

  1. Guest

    Hello
    I have application code that runs fine when executed from inside
    Eclipse IDE.
    However when I make a jar "myApp.jar" out of it then the jar does not
    run. If I however remove a certain object of a certain class C from my
    code and generates a new "myApp.jar", then the new jar runs fine
    aswell.

    The class C which I remove from the code to make it work is located in
    an external jar "x.jar".
    Inside the IDE, I have included x.jar in the buildpath of the project.

    My thought is that the class C is not found in runtime when executing
    "myApp.jar".

    Where should I put the x.jar for the JRE to find when executing
    myApp.jar?
     
    , Mar 26, 2008
    #1
    1. Advertising

  2. Donkey Hot Guest

    wrote in news:d6ad2e8f-d687-4048-8f22-44746f7cd069
    @t54g2000hsg.googlegroups.com:

    > Hello
    > I have application code that runs fine when executed from inside
    > Eclipse IDE.
    > However when I make a jar "myApp.jar" out of it then the jar does not
    > run. If I however remove a certain object of a certain class C from my
    > code and generates a new "myApp.jar", then the new jar runs fine
    > aswell.
    >
    > The class C which I remove from the code to make it work is located in
    > an external jar "x.jar".
    > Inside the IDE, I have included x.jar in the buildpath of the project.
    >
    > My thought is that the class C is not found in runtime when executing
    > "myApp.jar".
    >
    > Where should I put the x.jar for the JRE to find when executing
    > myApp.jar?


    To the classpath

    java -cp .;/path/to/the/x.jar;/possible/other/jars -jar myApp.jar
     
    Donkey Hot, Mar 26, 2008
    #2
    1. Advertising

  3. On Wed, 26 Mar 2008 03:44:35 -0700, marcussilfver wrote:

    > Hello
    > I have application code that runs fine when executed from inside Eclipse
    > IDE.
    > However when I make a jar "myApp.jar" out of it then the jar does not
    > run. If I however remove a certain object of a certain class C from my
    > code and generates a new "myApp.jar", then the new jar runs fine aswell.
    >
    > The class C which I remove from the code to make it work is located in
    > an external jar "x.jar".
    > Inside the IDE, I have included x.jar in the buildpath of the project.
    >
    > My thought is that the class C is not found in runtime when executing
    > "myApp.jar".
    >
    > Where should I put the x.jar for the JRE to find when executing
    > myApp.jar?



    Do a search for jar mainifest. That should tell you how to include x.jar
    in the classpath and make your jar file double clickable.

    I'm surprised Eclipse doesn't do this for you, or maybe it does but you
    aren't packaging it correctly after.

    For example, taking a similar approach as you have in Netbeans will
    create myApp.jar (horrible name) and put it in dist/. It will also put
    dependencies in the relative directory lib/, that is, dist/lib/. You can
    then copy the contents of dist/ anywhere and it will run.

    Check out what is in bin/ in Eclipse.

    Lionel.
     
    Lionel van den Berg, Mar 26, 2008
    #3
  4. Lew Guest

    wrote:
    >> I have application code that runs fine when executed from inside
    >> Eclipse IDE.
    >> However when I make a jar "myApp.jar" out of it then the jar does not
    >> run. If I however remove a certain object of a certain class C from my
    >> code and generates a new "myApp.jar", then the new jar runs fine
    >> aswell.
    >>
    >> The class C which I remove from the code to make it work is located in
    >> an external jar "x.jar".
    >> Inside the IDE, I have included x.jar in the buildpath of the project.
    >>
    >> My thought is that the class C is not found in runtime when executing
    >> "myApp.jar".
    >>
    >> Where should I put the x.jar for the JRE to find when executing
    >> myApp.jar?


    Donkey Hot wrote:
    > To the classpath
    >
    > java -cp .;/path/to/the/x.jar;/possible/other/jars -jar myApp.jar


    There's no point in putting a -cp option there if you use -jar. The classpath
    will be completely ignored due to the -jar option.

    <http://java.sun.com/javase/6/docs/technotes/tools/solaris/java.html>
    > When you use this option [-jar], the JAR file is the source of all user classes,
    > and other user class path settings are ignored.


    The answer is the Class-Path manifest attribute
    <http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html#Manifest%20Specification>

    Place the library JAR in the same directory as the application JAR, or a
    subdirectory, and reference it from the manifest of the application JAR.

    --
    Lew
     
    Lew, Mar 26, 2008
    #4
  5. Guest

    On 26 Mar, 13:54, Lew <> wrote:
    > wrote:
    > >> I have application code that runs fine when executed from inside
    > >> Eclipse IDE.
    > >> However when I make a jar "myApp.jar" out of it then the jar does not
    > >> run. If I however remove a certain object of a certain class C from my
    > >> code and generates a new "myApp.jar", then the new jar runs fine
    > >> aswell.

    >
    > >> The class C which I remove from the code to make it work is located in
    > >> an external jar "x.jar".
    > >> Inside the IDE, I have included x.jar in the buildpath of the project.

    >
    > >> My thought is that the class C is not found in runtime when executing
    > >> "myApp.jar".

    >
    > >> Where should I put the x.jar for the JRE to find when executing
    > >> myApp.jar?

    > Donkey Hot wrote:
    > > To the classpath

    >
    > > java -cp .;/path/to/the/x.jar;/possible/other/jars -jar myApp.jar

    >
    > There's no point in putting a -cp option there if you use -jar.  The classpath
    > will be completely ignored due to the -jar option.
    >
    > <http://java.sun.com/javase/6/docs/technotes/tools/solaris/java.html>
    >
    > > When you use this option [-jar], the JAR file is the source of all user classes,
    > > and other user class path settings are ignored.

    >
    > The answer is the Class-Path manifest attribute
    > <http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html#Manifest%20Spe...>
    >
    > Place the library JAR in the same directory as the application JAR, or a
    > subdirectory, and reference it from the manifest of the application JAR.
    >
    > --
    > Lew- Dölj citerad text -
    >
    > - Visa citerad text -


    thanks everyone answering. I got it working now!

    regards
    Marcus
     
    , Mar 26, 2008
    #5
  6. Roedy Green Guest

    On Wed, 26 Mar 2008 03:44:35 -0700 (PDT),
    wrote, quoted or indirectly quoted someone who said :

    >Where should I put the x.jar for the JRE to find when executing
    >myApp.jar?


    Normally you build jars with ant scripts. See
    http://mindprod.com/jgloss/ant.html

    You might have a look at some of my jars
    http://mindprod.com/products.html to see the structure. Look inside
    your jars to make sure all the class files are there and they are
    named correctly, and resources are present, and the manifest is
    correctly built.

    See http://mindprod.com/jgloss/jar.html
    http://mindprod.com/jgloss/jarexe.html
    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Mar 26, 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. Rick T.
    Replies:
    1
    Views:
    410
    Andrew Thompson
    Nov 30, 2004
  2. Replies:
    0
    Views:
    468
  3. Jerry
    Replies:
    2
    Views:
    120
  4. Owen
    Replies:
    5
    Views:
    417
    Yan-Hong Huang[MSFT]
    Feb 23, 2004
  5. Krzysztof Poc

    outside type, outside function

    Krzysztof Poc, Feb 3, 2012, in forum: C++
    Replies:
    1
    Views:
    313
    Victor Bazarov
    Feb 7, 2012
Loading...

Share This Page