Results 1 to 19 of 19

Thread: Deployment

  1. #1
    Join Date
    Nov 2012
    Posts
    9
    Rep Power
    0

    Default Deployment

    I'm trying to deploy a java program I wrote. I created a .jar file using NetBeans. When I click on that file (Windows 7) it brings up the Open with... dialogue box. I assume I have to associate .jar files with a jvm, however, I'm running other java programs

    I'd like to know how to create a regular java program that users can simply download and run. Thanks.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default Re: Deployment

    That's a Windows thing.
    Did you install the JRE/JDK?
    If so it should (though I have heard that sometimes it fails) have associated 'jar' with the javaw.exe in the JRE.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Join Date
    Nov 2012
    Posts
    9
    Rep Power
    0

    Default Re: Deployment

    Yes, I have a 32-bit and 64-bit JRE/JDK installed. If I "open with" the jar file using the javaw.exe in either JRE, i get and error -- "Could not find the main class."

    Of course there is a main class.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default Re: Deployment

    Is it defined?
    That is, do you have a manifest in the jar file?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    Join Date
    Nov 2012
    Posts
    9
    Rep Power
    0

    Default Re: Deployment

    That's a good question. I'm not sure. I just did a 'clean and build' with NetBeans, which created the jar file.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,247
    Rep Power
    19

    Default Re: Deployment

    Did you identify the main class in the NetBeans project properties?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    Join Date
    Nov 2012
    Posts
    9
    Rep Power
    0

    Default Re: Deployment

    No. I was just trying to figure out how though, with little luck. Does this have something to do with a 'manifest' file? Here's what the manifest.mf in my projects root folder has:

    Manifest-Version: 1.0
    X-COMMENT: Main-Class will be added automatically by build

  8. #8
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: Deployment

    The manifest file (among other things) tells java what class in the jar is the class with a main method. When you tell NetBeans which of the project classes is the main class, it will insert this information into the manifest file for you. If you make a jar from scratch, you need to specify it yourself.

  9. #9
    Join Date
    Nov 2012
    Posts
    9
    Rep Power
    0

    Default Re: Deployment

    I simply ran a 'clean and build' with NetBeans. I'm not sure if that's from scratch or not.

    I have the main class specified under Project Properties >> Run .. Main Class:

  10. #10
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: Deployment

    When I said from scratch, I mean outside of netbeans using the command line jar tool. Netbeans will do everything for you if you have your main specified like you said, a clean and build will put the jar file in your project's dist folder.

  11. #11
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: Deployment

    Oh yeah, and if it is not a gui application, the only way to run it is via command line with: java -jar myApp.jar

  12. #12
    Join Date
    Nov 2012
    Posts
    9
    Rep Power
    0

    Default Re: Deployment

    Why am I getting the error then? This is a GUI application, my main class is defined, but I still get the error.

  13. #13
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: Deployment

    Can you zip your netbeans project and put it online somewhere? I'll take a look.

  14. #14
    Join Date
    Nov 2012
    Posts
    9
    Rep Power
    0

    Default Re: Deployment

    Ok quad64bit, here it is: Wikisend: free file sharing service

    Thanks

  15. #15
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: Deployment

    Yeah, so it works fine for me! I ran the jar with a double click, it opened right up:

    Deployment-screen-shot-2012-11-16-10.09.47-am.png

  16. #16
    Join Date
    Nov 2012
    Posts
    9
    Rep Power
    0

    Default Re: Deployment

    So what could be the problem with my setup? I'm running Win 7 Pro.

  17. #17
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: Deployment

    It could be? I'm not really sure. Windows is kind of a pain with that kinda thing. Verify that all your paths are set correctly. Can you run any java stuff from the command line?

  18. #18
    Join Date
    Nov 2012
    Posts
    9
    Rep Power
    0

    Default Re: Deployment

    Yeah, it runs fine from cmd. I have .jar files associated with a javaw.exe in the JRE.

  19. #19
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: Deployment

    So you can run the jar from command line, just not from a double click. Hmmm, I'm really not sure. It's got to be a windows config thing though - I bet if you tried it in a linux virtual machine it'd work fine.

Similar Threads

  1. jar Deployment
    By hsenpaws in forum New To Java
    Replies: 1
    Last Post: 06-26-2012, 06:35 PM
  2. deployment of the project
    By amit khutwad in forum NetBeans
    Replies: 0
    Last Post: 03-15-2011, 05:02 PM
  3. Deployment
    By rob in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 04-08-2009, 10:03 PM
  4. hot deployment
    By Manas Das in forum Advanced Java
    Replies: 0
    Last Post: 01-21-2009, 05:24 PM
  5. deployment
    By Nicholas Jordan in forum NetBeans
    Replies: 4
    Last Post: 07-09-2008, 05:10 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
  •