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 12 of 12

Thread: A problem in creating and using packages

  1. #1
    Junior Member
    Join Date
    Aug 2017
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question A problem in creating and using packages

    Hi.

    The problem I have is most likely of my own doing. Still, I hope my question won't be met with derision.

    I've been programming Java from its appearance in 1997 till about 10 years ago when browsers began experience difficulty loading Java.

    I own a web site Interactive Mathematics Miscellany and Puzzles and, while at it, I wrote about 1000 Java applets to present math concepts, problems and puzzles. Nothing at the professional level. Since math and not programming per se was my interest, I stuck to the approach Java allowed originally. I would store my applets and libraries in zip files and invoke them, e.g., as

    <applet code="appletName" codebase="classDirectory" archive="applet.zip,library1.zip,library2.zip">

    A few months ago, Firefox - the last browser that yet let my applets run - stopped supporting its Java add-on.

    Now, I purchased a code signing certificate, converted some zipped applets into jar files and the converted applets load in IE11 and Safari. I'd like to simplify the process.

    The problem is that libraries must be converted to packages and imported into the code. In my view, I did everything right. I added "package myLibrary;" as the first line to every Java file in the library, compiled them into a jar file (I work in eclipse, so I Export'ed the declared package into a jar file), added "import myLibrary;" to the applet.java. The result was an error message: "The import myLibrary cannot be resolved" although I added the jar file to the project's library list.

    What is wrong? Thank you for your help.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,381
    Thanks
    53
    Thanked 2,397 Times in 2,350 Posts

    Default Re: A problem in creating and using packages

    The import myLibrary cannot be resolved
    Is that a compiler error?
    Is the folder: myLibrary on the classpath when the javac command is executed?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Aug 2017
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: A problem in creating and using packages

    Thank you for looking into that.

    1) Yes, it is reported by eclipse
    2) I ran another project that used 3rd party jars. All it took in eclipse was to declare those jar as libraries. And it worked too. Doing this with a jar of my own creation did not. As it's not a command line, the CLASSPATH is not needed.

    The problem I think is in how I create the package for my library

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,381
    Thanks
    53
    Thanked 2,397 Times in 2,350 Posts

    Default Re: A problem in creating and using packages

    Sorry, I don't use eclipse and can't help you set it up for compiling your programs.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Aug 2017
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: A problem in creating and using packages

    Thank you, anyway

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,381
    Thanks
    53
    Thanked 2,397 Times in 2,350 Posts

    Default Re: A problem in creating and using packages

    Have you tried using the commandline with the javac and jar commands?
    I make batch files with those commands to build my jar files.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Aug 2017
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: A problem in creating and using packages

    I shall. This is on my "to do" list now. Thank you

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,381
    Thanks
    53
    Thanked 2,397 Times in 2,350 Posts

    Default Re: A problem in creating and using packages

    The problem is that libraries must be converted to packages
    Can you explain why the code must be in packages?

    Can you post a link to one of your pages with an applet?

    I have a page with applet without packages:
    http://normsstuff.x10host.com/SmallBlob.html
    Next one is in a package:
    http://normsstuff.x10host.com/WayPoints.html

    These both work in IE

    I have the site in the Java Console's Exception Site List and my security level is at High
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Aug 2017
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: A problem in creating and using packages

    >Can you explain why the code must be in packages?

    To avoid naming conflicts

    >Can you post a link to one of your pages with an applet?

    1) A converted applet with an external library
    Proizvolov's identity in a game format

    Mind please thall my applets are 10 years old on average.

    2) And here is the one that I did not convert yet

    Memory Puzzle - Midium Difficulty

    When I say converted I mean that I simply added all the files needed to run the applet, also from my libraries, to that project as I wanted to check that my certificate was doing its job. Apparently it does. I converted just a few applets. Now I decided to do something more intelligent and use libraries, as one would expect.

    > I have a page with applet without packages:
    > These both work in IE

    They did not for me. When I wanted to declare the site trusted, IE requested HTTPS.
    I went to Internet Options / Trusted sites.

    > I have the site in the Java Console's Exception Site List and my security level is at High[/QUOTE]

    How do I get there?

    I very much appreciate your interest and assistance

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,381
    Thanks
    53
    Thanked 2,397 Times in 2,350 Posts

    Default Re: A problem in creating and using packages

    The Exception Site list has this entry
    http://normsstuff.x10host.com/

    I did not make any settings in IE. When I load the page in IE, I got a security prompt which I accepted and IE loaded and displayed the page.
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Aug 2017
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: A problem in creating and using packages

    I see. It is Java settings, not IE. I have this for my site. But still IE does not run. I am going to check your site.

    --- Update ---

    Interesting. Your applets do work. Both of them - with and without package. My do not mine?

  12. #12
    Junior Member
    Join Date
    Aug 2017
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: A problem in creating and using packages

    I am sorry. The applets do run in IE11, all in the old setup of zip files. It may still be a good idea to learn how to create packages but it is less urgent now. Thank you for setting this straight for me

Similar Threads

  1. To creating user defined packages
    By vishvaD in forum What's Wrong With My Code?
    Replies: 5
    Last Post: September 1st, 2014, 03:40 PM
  2. Problem with packages.
    By fkmk in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 9th, 2014, 05:18 PM
  3. Replies: 0
    Last Post: July 24th, 2013, 07:17 AM
  4. problem with creating .pdf
    By deepanshu in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 18th, 2013, 05:16 AM
  5. Problem with Packages
    By pirezas in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 12th, 2010, 02:41 PM

Tags for this Thread