Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Hi, new user with .JAR creation problem

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Hi, new user with .JAR creation problem

    Background: Having been in the Java world from 1999-2001, I left it for the PHP world and came back to the Java world in 2013. I'm having to learn and relearn a whole bunch of things.

    I'm trying to implement UPS shipping modules into a web app I'm building. My task is to convert this (along with other shipping code) into a JAR file.

    Her'es the problem. One of the principal classes (UPS provided code) contains external resources in the form of .WSDL files.

    url = new URL("file:src/com/ups/wsdl/RateWS.wsdl");

    This URL (class java.net.URL) is fed into a constructor of the class "RateService" which is an extension of javax.xml.ws.Service.

    This makes the .JAR file unusable because it coughs up execution errors when it comes across that statement; the .wsdl file being not found.

    So. Here's the tricky question: How do I wrap that .wsdl into the JAR in such a manner that the code can 'see' it? Or can I simply turn the .wsdl into a long string somehow and feed it into the Service? (Far as I can tell, the Service requires a URL of some kind, not simply a big string).

    I'm banging my head against the wall here, and after fifteen years as a developer I feel like a noob all over again (I'm also a novice at creating .JAR files at all!) and so I am begging y'all for some help here.

    Thanks.
    Last edited by blab; August 21st, 2014 at 11:38 AM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Hi, new user with .JAR creation problem

    Put the file into the jar file and treat it as a resource. The Class class's getResource() method returns a URL to the file.

    I use the jar command(comes with the JDK) to build my jar files.

    IDEs have settings that will include user selected files in the jar files they create.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Aug 2014
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Hi, new user with .JAR creation problem

    OK, this is a good start to help my addled brain figure this out.

    So being unfamiliar with getResource() -- is there a way to wedge getResource into either java.net.URL or javax.xml.ws.Service?

    I'll see if I can answer this question myself with a little research but if you know the quick answer, I'm all ears too.

    --- Update ---

    Oh, answered it myself almost instantly. getResource() returns a URL. This should work. Thank you, Norm.

    --- Update ---

    Implemented the rebranding (slightly tricky as the context was static so I had to do RateService.class.getResource()) and packaged the .jar and it worked. Norm, you're the man. Thank you.

    One of these days I'm going to research why getResource() is so magical within a .jar file...

Similar Threads

  1. Need help on jar file creation and usage
    By ritoban in forum Java IDEs
    Replies: 3
    Last Post: November 17th, 2013, 03:37 AM
  2. Problem with file creation
    By hliasprev in forum Threads
    Replies: 5
    Last Post: May 29th, 2013, 02:37 AM
  3. Problem of Making Jar
    By cppcppcpp in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 27th, 2012, 11:54 AM
  4. Apache XML-RPC server creation problem
    By r0x in forum What's Wrong With My Code?
    Replies: 0
    Last Post: October 10th, 2011, 09:52 AM
  5. [SOLVED] minesweeper game creation problem
    By kaylors in forum What's Wrong With My Code?
    Replies: 5
    Last Post: June 27th, 2009, 04:06 PM