Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Making an application

Options
  • 23-03-2004 2:48pm
    #1
    Closed Accounts Posts: 999 ✭✭✭


    Would anyone be able to show me how to go about creating an application with Java. Or even a link to a tutorial on it.
    At the moment I've got about 10 class files and I'd like to put them together into some kind of deliverable product say. I have apache Ant set up on my system and I can figure out the build.xml file alright but I don't understand how everything should be put together i.e. how folders should be arranged or how .jar files work.
    Can anyone help clear this up for me?


Comments

  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Well, unless you've been specifying packages, you'll be keeping all your files in the same folder. I take it you have strung all your classes together and run them all from one class with a main method? If not, you've a bit of work to do yet. If so, congrats if it works, you've written an application.

    All you need now is read Using JAR Files: The Basics on java.sun.com


  • Closed Accounts Posts: 999 ✭✭✭Raz


    I've attempted to use packages but I couldn't get it to run when I did because I really just didn't have a clue what I was doing. All I could see was that I was organising the classes into folders but I couldn't run them from a base folder and I assumed that was what the JAR file was for.
    I'll have a read through the guide and should be set on a much more straight forward path.
    And for the hell of it, here's a screen grab of the application. It's a simulator for the Motorola MC6809 Processor.


  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Well, for packages, you need to have the package declaration at the top of the page. If your using external packages that you've created yourself, you'll need to add the path to the class path, let the compiler know where they are.

    If they're part of the same application, add package projectname; to the top of every class. All the classes will be arranged in a folder called project name.


  • Closed Accounts Posts: 999 ✭✭✭Raz


    Okay, I've been studying up on the whole jar file thing but I've can't seem to get my program running from the jar. I've added the line "Main-Class: Run" to the manifest but when I try to use "java -jar MVM.jar" I get this,

    Exception in thread "main" java.io.IOException: invalid manifest format
    at java.util.jar.Manifest.read(Manifest.java:193)
    at java.util.jar.Manifest.<init>(Manifest.java:52)
    at java.util.jar.JarFile.getManifest(JarFile.java:158)

    The tutorial you linked to doodle was written at the j2sdk1.2.2 time I think so has there been any changes to the way it operates?
    I also couldn't get the jar file to update. I got this,

    PROMPT$ jar uvmf mani MVM.jar *.class
    jar: `-u' mode unimplemented.


    any ideas?


  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Well, it looks like your after specifying something incorrectly in the manifest. Take a look at the specifications for the Jar manifest.

    As for the documentation, it applies to all versions above 1.2 unless it specifies that a feature is only available in a certain version (usually 1.2)


  • Advertisement
  • Closed Accounts Posts: 999 ✭✭✭Raz


    Well I've gotten it running from the jar file which is nice. I'd still like to get some kind of structure to the folders and all but I suppose I'll have to learn a bit more about packages to do that.
    Thanks for the help doodle :)


  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    No problem :D You get the updating working alright? Afraid I can't help you with that without more information...


  • Closed Accounts Posts: 999 ✭✭✭Raz


    No, didn't get the update working but then I didn't try again once I'd gotten the jar to work, so maybe it'll work with a correct manifest. It doesn't really matter anyhow, making a new jar file each time isn't really much different.


Advertisement