Professional Web Applications Themes

java "package" statement with XCode - Mac Programming

I have a small project from NetBeans that I would like to "import" into XCode. It is a Swing app. I do "New Project" for a Swing Application. I can't get my directory structure/package structure into the project. I add the files but I get class not found exceptions. I then tried to make a simple Java Tool with a 3 level deep package structure. The tool generated a class with a Main. It did not ask any info for creating a package or anything. I just don't understand XCode. Does it only work with the default package? How do ...

  1. #1

    Default java "package" statement with XCode

    I have a small project from NetBeans that I would like to "import"
    into XCode.
    It is a Swing app.
    I do "New Project" for a Swing Application. I can't get my directory
    structure/package structure into the project. I add the files but I
    get class not found exceptions.

    I then tried to make a simple Java Tool with a 3 level deep package
    structure.
    The tool generated a class with a Main. It did not ask any info for
    creating a package or anything.

    I just don't understand XCode.
    Does it only work with the default package?
    How do I set up a simple example for a java tool?
    I would like something like:

    package org.mystuff.teststuff;
    import ...
    public class TheClass {
    public void Main...


    Thanks!
    sirgilligan Guest

  2. #2

    Default Re: java "package" statement with XCode

    sirgilligan <com> wrote:

    []
     

    []
     

    you mean 'public _static_ void main' I hope...

    xCode creates .jar files, which are double-clickable if you provide the
    name of the class that contains the 'main' in the manifest file. So
    change the name to that of your class.

    Note that you must specify the full name, so

    'Main-Class: org.mystuff.teststuff.TheClass'.

    This line _must_ be followed by a 'return', otherwise it won't work.
    You should also be able to start your product from the command line:

    'java -jar myjar.jar org.mystuff.teststuff.TheClass'.

    That's why I prefer to keep my 'main' class out of any pacakges ;-)

    Patrick
    Patrick Guest

  3. #3

    Default Re: java "package" statement with XCode

    > xCode creates .jar files, which are double-clickable if you provide the 

    So, the only way is to hand edit the maifest file. Wow.

    What if you want to make a library (jarred up) with a package structure?

    package org.mystuff.teststuff
    import ...
    public class Multiply {
    public int calc(int a, int b) {
    return a * b;
    }
    }

    and another class in another file of course

    package org.mystuff.teststuff
    import...
    public class Add {
    public int calc(int a, int b) {
    return a + b;
    }
    }

    When you create a project there is no package layout specified.

    Gilligan
    sirgilligan Guest

  4. #4

    Default Re: java "package" statement with XCode

    sirgilligan <com> wrote:
     

    I think that is the case, yes.
     

    If by 'package structure' you mean the creation of the virtual folder
    structure /org/mystuff/teststuff/, this is done automatically by the jar
    tool. (which is why you have to start jarred up apps with their fully
    qualified name)

    patrick
    Patrick Guest

Similar Threads

  1. Can't locate object method "newFromJpeg" via package "GD::Image"
    By francescomoi@usa.com in forum PERL Modules
    Replies: 3
    Last Post: December 20th, 11:39 AM
  2. Can't locate object method "blocking" via package "IO::Handle"
    By kemton@kemton.com in forum PERL Modules
    Replies: 1
    Last Post: June 20th, 02:54 PM
  3. Replies: 2
    Last Post: April 15th, 01:41 PM
  4. Can't not locate object method "isadmin" via package "Noc1"
    By Perldiscuss - Perl Newsgroups And Mailing Lists in forum PERL Beginners
    Replies: 1
    Last Post: November 13th, 03:34 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139