How Do I Publish My Working Project (corresponding dot jar doesn'twork on other's PCs)

Discussion in 'Java' started by clusardi2k@aol.com, Sep 7, 2012.

  1. Guest

    Hello,

    Once my NetBeans project is finalized what do I have to do to create an executable others can execute without having NetBeans directly installed on the computer.

    Currently, my project contains a dot jav file which I can run to execute myproject. But, when others try to execute that same dot jar it doesn't work.. (Am I missing something here or should executing the dot jar always work.How should I troubleshoot this problem.)

    Thank you,
    , Sep 7, 2012
    #1
    1. Advertising

  2. Re: How Do I Publish My Working Project (corresponding dot jardoesn't work on other's PCs)

    <> wrote:
    > Once my NetBeans project is finalized what do I have to do to create an executable others can execute without having NetBeans directly installed on the computer.
    > Currently, my project contains a dot jav file which I can run to execute my project. But, when others try to execute that same dot jar it doesn't work. (Am I missing something here or should executing the dot jar always work. How should I troubleshoot this problem.)


    Maybe a trivial question, but do they have Java installed?

    (I mean, they shouldn't need netbeans, but they will need
    at least a Java Runtime Environment (jre) to run jar files.)
    Andreas Leitgeb, Sep 7, 2012
    #2
    1. Advertising

  3. Re: How Do I Publish My Working Project (corresponding dot jar doesn't work on other's PCs)

    In article <>,
    Andreas Leitgeb <> wrote:

    > <> wrote:
    > > Once my NetBeans project is finalized what do I have to do to
    > > create an executable others can execute without having NetBeans
    > > directly installed on the computer. Currently, my project contains
    > > a dot jav file which I can run to execute my project. But, when
    > > others try to execute that same dot jar it doesn't work. (Am I
    > > missing something here or should executing the dot jar always work.
    > > How should I troubleshoot this problem.)

    >
    > Maybe a trivial question, but do they have Java installed?
    >
    > (I mean, they shouldn't need netbeans, but they will need
    > at least a Java Runtime Environment (jre) to run jar files.)


    Java Web Start appears to address this on supported platforms in the
    href provided to the version attribute of the j2se tag. I've never
    actually tried it, as my platform vendor supplies the JRE.

    <http://stackoverflow.com/tags/java-web-start/info>

    --
    John B. Matthews
    trashgod at gmail dot com
    <http://sites.google.com/site/drjohnbmatthews>
    John B. Matthews, Sep 7, 2012
    #3
  4. Nigel Wade Guest

    On 07/09/12 13:15, wrote:
    > Hello,
    >
    > Once my NetBeans project is finalized what do I have to do to create an executable others can execute without having NetBeans directly installed on the computer.
    >
    > Currently, my project contains a dot jav file which I can run to execute my project. But, when others try to execute that same dot jar it doesn't work. (Am I missing something here or should executing the dot jar always work. How should I troubleshoot this problem.)
    >
    > Thank you,



    What type of project did you create in NetBeans? Was it a Java
    Application? Only this type of project creates the necessary manifest in
    the project jar for it to be run simply by the java -jar project.jar
    command. There are also some other constraints which if they are not met
    will cause NetBeans to not create an "executable" jar. Offhand I cannot
    remember what they are, and I've not had this problem re-occur for some
    time.

    A NetBeans Java Application should create a dist/ directory containing
    the actual project jar, and a dist/lib directory containing any required
    additional jars. It should also include an appropriate manifest in the
    project jar which makes the jar "executable" (i.e. has a Main-Class
    property). It also includes the lib/ directory in the jar Classpath.

    Check the contents of your dist/ directory, and the project jar. If it
    doesn't include these features then it's not a proper Java "application"
    jar. That may mean that you didn't create it correctly, or NetBeans has
    cocked up (technical term) the project properties (this does happen). If
    this does happen the simplest alternative is to create a new Java
    Application project and copy all your sources into it. Fixing it
    manually requires dexterous manipulation of, IIRC, project.properties
    and build-impl.xml. Creating a new project is simpler, quicker, and less
    likely to bite you back in the future.

    --
    Nigel Wade
    Nigel Wade, Sep 7, 2012
    #4
  5. Lew Guest

    Re: How Do I Publish My Working Project (corresponding dot jardoesn't work on other's PCs)

    Nigel Wade wrote:
    > What type of project did you create in NetBeans? Was it a Java
    > Application? Only this type of project creates the necessary manifest in
    >
    > the project jar for it to be run simply by the java -jar project.jar


    Not exactly. You can certainly edit the manifest in a normal JAR project or
    normal Java project. I haven't worked with the "Java Application" NetBeans
    project, but I've seen some complaints about it in this forum. Just set
    "Main-Class:"

    Read the Oracle site docs about JARs and JAR manifests. Your customers
    can run JARs via Java WebStart, as mentioned, or directly by associating
    "java -jar" with JAR files (might need "javaw -jar" on Windows platforms).

    http://docs.oracle.com/javase/tutorial/deployment/jar/manifestindex.html

    > command. There are also some other constraints which if they are not met
    > will cause NetBeans to not create an "executable" jar. Offhand I cannot
    > remember what they are, and I've not had this problem re-occur for some
    > time.
    >
    > A NetBeans Java Application should create a dist/ directory containing
    > the actual project jar, and a dist/lib directory containing any required
    > additional jars. It should also include an appropriate manifest in the
    > project jar which makes the jar "executable" (i.e. has a Main-Class
    > property). It also includes the lib/ directory in the jar Classpath.


    The manifest's "Class-Path:" header, which specifies paths relative
    to the JAR location on the target system.

    > Check the contents of your dist/ directory, and the project jar. If it
    > doesn't include these features then it's not a proper Java "application"
    > jar. That may mean that you didn't create it correctly, or NetBeans has
    > cocked up (technical term) the project properties (this does happen). If
    > this does happen the simplest alternative is to create a new Java
    > Application project and copy all your sources into it. Fixing it
    > manually requires dexterous manipulation of, IIRC, project.properties
    > and build-impl.xml. Creating a new project is simpler, quicker, and less
    > likely to bite you back in the future.


    You don't need to futz with NB-specific files if you edit manifests yourself,
    and also you should build from "build.xml", not IDE-specific artifacts.

    --
    Lew
    Lew, Sep 7, 2012
    #5
  6. Re: How Do I Publish My Working Project (corresponding dot jar doesn't work on other's PCs)

    In article <>,
    Lew <> wrote:

    > > Check the contents of your dist/ directory, and the project jar. If
    > > it doesn't include these features then it's not a proper Java
    > > "application" jar. That may mean that you didn't create it
    > > correctly, or NetBeans has cocked up (technical term) the project
    > > properties (this does happen). If this does happen the simplest
    > > alternative is to create a new Java Application project and copy
    > > all your sources into it. Fixing it manually requires dexterous
    > > manipulation of, IIRC, project.properties and build-impl.xml.
    > > Creating a new project is simpler, quicker, and less likely to bite
    > > you back in the future.

    >
    > You don't need to futz with NB-specific files if you edit manifests
    > yourself, and also you should build from "build.xml", not
    > IDE-specific artifacts.


    I like the flexibility NetBeans affords in this area:

    For convenience, I can use the stock, NB-generated build.xml, even from
    the command line, and hook into it as needed:

    <http://stackoverflow.com/q/3955299/230513>

    Alternatively, I can add a small number of targets to my custom
    build.xml, and NB will happily adopt it in a free-form project:

    <http://netbeans.org/kb/articles/freeform-config.html>

    For example:

    <https://sites.google.com/site/drjohnbmatthews/manifesto>

    --
    John B. Matthews
    trashgod at gmail dot com
    <http://sites.google.com/site/drjohnbmatthews>
    John B. Matthews, Sep 8, 2012
    #6
  7. Roedy Green Guest

    Re: How Do I Publish My Working Project (corresponding dot jar doesn't work on other's PCs)

    On Fri, 7 Sep 2012 05:15:00 -0700 (PDT), wrote,
    quoted or indirectly quoted someone who said :

    >Once my NetBeans project is finalized what do I have to do to create an exe=
    >cutable others can execute without having NetBeans directly installed on th=
    >e computer.


    You can bundle it up into a jar.
    see http://mindprod.com/jgloss/jar.html


    You can compile the Java with jet to an exe
    see http://mindprod.com/jgloss/jet.html
    --
    Roedy Green Canadian Mind Products http://mindprod.com
    A new scientific truth does not triumph by convincing its opponents and making them see the light,
    but rather because its opponents eventually die, and a new generation grows up that is familiar with it.
    ~ Max Planck 1858-04-23 1947-10-04
    Roedy Green, Sep 8, 2012
    #7
  8. Guest

    Re: How Do I Publish My Working Project (corresponding dot jardoesn't work on other's PCs)

    Help, all I need is:

    (1) the JDK (which one, The jars were created with NetBeans 7.1.2),

    (2) put /dist/lib/*.jars" into my classpath environment variable, and

    (3) possibly use "java -jar" and "javaw -jar"?

    Thank you,
    , Sep 11, 2012
    #8
  9. Lew Guest

    Re: How Do I Publish My Working Project (corresponding dot jardoesn't work on other's PCs)

    (unknown) wrote:
    > Help, all I need is:
    >
    > (1) the JDK (which one, The jars were created with NetBeans 7.1.2),


    That depends on how you have NetBeans and the particular project
    configured.

    Which JDK did you configure the project to use?

    > (2) put /dist/lib/*.jars" into my classpath environment variable, and


    What? Huh?

    You shouldn't be messing around with root-level
    directories like that.

    Put your project directory under your home directory or
    in some suitable location like /projects/.

    > (3) possibly use "java -jar" and "javaw -jar"?


    What do you mean?

    The "-jar" parameter to those commands specifies a JAR
    file for Java to run, if that's what you're asking.

    --
    Lew
    Lew, Sep 11, 2012
    #9
  10. Guest

    Re: How Do I Publish My Working Project (corresponding dot jardoesn't work on other's PCs)

    On Tuesday, September 11, 2012 2:49:00 AM UTC-4, Lew wrote:
    > (unknown) wrote: > Help, all I need is: > > (1) the JDK (which one, The jars were created with NetBeans 7.1.2), That depends on how you have NetBeans and the particular project configured. Which JDK did you configure the project to use? > (2) put /dist/lib/*.jars" into my classpath environment variable, and What? Huh? You shouldn't be messing around with root-level directories like that. Put your project directory under your home directory or in some suitable location like /projects/. > (3) possibly use "java -jar" and "javaw -jar"? What do you mean? The "-jar" parameter to those commands specifies a JAR file for Java to run, if that's what you're asking. -- Lew


    On NetBeans, how do I determine what JDK I'm using. I forgot which one I loaded.

    Thanks,
    , Sep 11, 2012
    #10
  11. markspace Guest

    On 9/11/2012 5:12 AM, wrote:

    > On NetBeans, how do I determine what JDK I'm using. I forgot which
    > one I loaded.



    It's in your project properties. And it's not the one you have loaded,
    it's the one you have set for the build target. In other words, if you
    are using JDK 7, you can still be targeting for example Java 5 in your
    project, which is useful if you have users still on Java 5 who don't
    want to upgrade.

    Right-click on the project, Properties -> Sources, way down at the
    bottom it says "Sources/Binary Format", that's your target (I'm using NB
    7.2 btw, I seem to remember a slightly different option format in NB 6).

    Also, you need the JRE. The JDK is for development, your users won't
    normally need that. All they need is the normal runtime, the JRE. You
    personally can use the JDK, because it contains a JRE, but anyone else
    will normally just have the JRE.

    To run, you use java -cp <path to all needed jars> -jar <path/your jar>

    If you need to do fancier things than that (distribute over the
    internet, for example) then look into Java WebStart or consider OneJar
    if you are going to just copy the files around.
    markspace, Sep 11, 2012
    #11
  12. Lew Guest

    Re: How Do I Publish My Working Project (corresponding dot jardoesn't work on other's PCs)

    markspace wrote:
    > To run, you use java -cp <path to all needed jars> -jar <path/your jar>


    The problem with that is that the command will ignore the "-cp" parameter.

    "-cp" and "-jar" is either/or proposition.

    --
    Lew
    Lew, Sep 11, 2012
    #12
  13. markspace Guest

    On 9/11/2012 11:08 AM, Lew wrote:
    > markspace wrote:
    >> To run, you use java -cp <path to all needed jars> -jar <path/your jar>

    >
    > The problem with that is that the command will ignore the "-cp" parameter.
    >
    > "-cp" and "-jar" is either/or proposition.
    >



    Yes I totally forgot about that. I guess I don't actually run java from
    the command line very often.

    That leaves setting the classpath in the jar itself, which is kind of
    tricky if you are going to be moving the jar to other people's
    computers. Java WebStart and OneJar come in handy here.

    Classpath in a jarfile:

    <http://docs.oracle.com/javase/tutorial/deployment/jar/downman.html>
    markspace, Sep 11, 2012
    #13
  14. Guest

    Re: How Do I Publish My Working Project (corresponding dot jardoesn't work on other's PCs)

    On Tuesday, September 11, 2012 12:25:45 PM UTC-4, markspace wrote:
    > On 9/11/2012 5:12 AM, ... wrote: > On NetBeans, how do I determine what JDK I'm using. I forgot which > one I loaded. It's in your project properties. And it's not the one you have loaded, it's the one you have set for the build target. In other words, if you are using JDK 7, you can still be targeting for example Java 5 in your project, which is useful if you have usersstill on Java 5 who don't want to upgrade. Right-click on the project, Properties -> Sources, way down at the bottom it says "Sources/Binary Format",that's your target (I'm using NB 7.2 btw, I seem to remember a slightly different option format in NB 6). Also, you need the JRE. The JDK is for development, your users won't normally need that. All they need is the normal runtime, the JRE. You personally can use the JDK, because it contains a JRE,but anyone else will normally just have the JRE. To run, you use java -cp <path to all needed jars> -jar <path/your jar> If you need to do fancier things than that (distribute over the internet, for example) then look into Java WebStart or consider OneJar if you are going to just copy the files around.


    How do I determine the specific JRE that I need.

    Thanks,
    , Sep 12, 2012
    #14
  15. markspace Guest

    On 9/11/2012 4:21 PM, wrote:

    > On Tuesday, September 11, 2012 12:25:45 PM UTC-4, markspace wrote:


    >> Right-click on the project, Properties ->
    >> Sources, way down at the bottom it says "Sources/Binary Format",
    >> that's your target


    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    > How do I determine the specific JRE that I need.



    Reading the replies you get on this newsgroup would be a good start.
    markspace, Sep 12, 2012
    #15
  16. Guest

    Re: How Do I Publish My Working Project (corresponding dot jardoesn't work on other's PCs)

    On Tuesday, September 11, 2012 3:45:42 PM UTC-4, markspace wrote:
    > On 9/11/2012 11:08 AM, Lew wrote: > markspace wrote:
    > That leaves setting the classpath in the jar itself, which is kind of tricky if
    > you are going to be moving the jar to other people's computers. Java WebStart
    > and OneJar come in handy here. Classpath in a jarfile:
    > <http://docs.oracle.com/javase/tutorial/deployment/jar/downman.html>


    I just saw this article on the Internet. My guess is I should ignore this article, right?

    http://ac-support.europe.umuc.edu/~arnoldyl/NetBeansTutorials/Setting-Classpath.html

    Thanks,
    , Sep 12, 2012
    #16
  17. Guest

    Re: How Do I Publish My Working Project (corresponding dot jardoesn't work on other's PCs)

    > On Wednesday, September 12, 2012 10:24:20 AM UTC-4, (unknown) wrote:
    >> On Tuesday, September 11, 2012 3:45:42 PM UTC-4, markspace wrote:
    >> On 9/11/2012 11:08 AM, Lew wrote:
    >> markspace wrote:
    >> That leaves setting the classpath in the jar itself, which is kind of tricky if
    >> you are going to be moving the jar to other people's computers. Java WebStart
    >> and OneJar come in handy here. Classpath in a jarfile:
    >> <http://docs.oracle.com/javase/tutorial/deployment/jar/downman.html
    >> I just saw this article on the Internet. My guess is I should ignore this
    >> article, right? http://ac-
    >> support.europe.umuc.edu/~arnoldyl/NetBeansTutorials/Setting-Classpath.html


    I added the path to all my dot jars into an environment variable (user varianble and not a system variable) called classpath and was unable to run the project. I mean nothing happened.

    Via the Control Panel, I have the following programs installed on my friend's computer:

    Java 7 Update 7
    Java SE Development Kit 7 Update 7
    Java(TM) 6 Update 34
    Java(TM) 6 Update 34 (64-bit)

    What's up? What do I do.

    Thank you,
    , Sep 12, 2012
    #17
  18. markspace Guest

    On 9/12/2012 8:00 AM, wrote:

    >>>

    > I added the path to all my dot jars into an environment variable
    > (user varianble and not a system variable) called classpath and was
    > unable to run the project. I mean nothing happened.
    >


    Learn to debug. Add some print statements so you can trace the
    execution of your program. Attach a debugger.

    If nothing happens, that's because your app did nothing. Java will
    print an error message if it finds a problem.
    markspace, Sep 12, 2012
    #18
  19. Guest

    Re: How Do I Publish My Working Project (corresponding dot jardoesn't work on other's PCs)

    >On Wednesday, September 12, 2012 11:21:45 AM UTC-4, markspace wrote:
    >> On 9/12/2012 8:00 AM, ... wrote:
    >> I added the path to all my dot jars into an environment variable
    >> (user varianble and not a system variable) called classpath and was
    >> unable to run the project. I mean nothing happened.

    >
    > Learn to debug. Add some print statements so you can trace the execution of
    > your program. Attach a debugger. If nothing happens, that's because your app
    > did nothing. Java will print an error message if it finds a problem.


    I added the following as the first executable statement (etc) in the project:

    System.out.println("Hello 1");

    I then ran the project on my friend's PC using the Command Prompt and the command: java testing.jar

    I received the error message:

    Exception in thread "main" java.lang.NoClassDefFoundError: testing/jar
    Caused by: java.lang.ClassNotFoundException: testing.jar
    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)
    Could not find the main class: testing.jar. Program will exit.

    Thank you,
    , Sep 12, 2012
    #19
  20. Guest

    Re: How Do I Publish My Working Project (corresponding dot jardoesn't work on other's PCs)

    On my own PC under NetBeans, I have no problem. I see the following from five print statements!

    init:
    Deleting: C:\testing\build\built-jar.properties
    deps-jar:
    Updating property file: C:\testing\build\built-jar.properties
    files are up to date
    compile:
    run:
    Hello 1
    Hello 2
    Hello 3
    Hello 4
    Hello 5
    BUILD SUCCESSFUL (total time: 19 seconds)

    Thank you,
    , Sep 12, 2012
    #20
    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. Arnold Peters
    Replies:
    0
    Views:
    544
    Arnold Peters
    Jan 5, 2005
  2. Tim Royal
    Replies:
    0
    Views:
    701
    Tim Royal
    Aug 28, 2008
  3. krishnan

    Dot Net Project Execution without Dot Net and Framework....

    krishnan, Jan 7, 2006, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    167
    krishnan
    Jan 7, 2006
  4. Xeno Campanoli
    Replies:
    4
    Views:
    132
    Kyle Schmitt
    Apr 10, 2008
  5. Replies:
    6
    Views:
    218
    Thomas 'PointedEars' Lahn
    Dec 12, 2005
Loading...

Share This Page