Results 1 to 6 of 6
  1. #1
    ghostlyfoot is offline Member
    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    Post Confused with JAR Files.

    I use Eclipse to make things in Java. I just got finished with my first GUI (swing) project, and I was exited to run it on every computer in the house. xD
    So I right-click on my project, hit 'export', and then make an executable jar file. I double-clicked this file on my computer and it worked fine, but when i burned it to a cd-r and ran it on a different computer, it said it could not find my main. Does anyone know what is going on.

    (Yes, both PCs have the JRE.)

  2. #2
    SnakeDoc is offline Senior Member
    Join Date
    Apr 2012
    Posts
    129
    Rep Power
    0

    Default Re: Confused with JAR Files.

    perhaps u compiled as an Applet? I believe applets don't have a Main. -- Eclipse compiles on the fly when u run it I believe... so that may be your problem is wrong exprot type?

  3. #3
    ghostlyfoot is offline Member
    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    Default Re: Confused with JAR Files.

    Library Handling:
    Extract Libs into jar
    Package Libs into jar
    Create directory

    Does it matter which one of these I choose? Do I have to put the class files into the same folder as the jar?

  4. #4
    SnakeDoc is offline Senior Member
    Join Date
    Apr 2012
    Posts
    129
    Rep Power
    0

    Default Re: Confused with JAR Files.

    hmm... not sure... sorry...

    perhaps just try to compile the program (into .class file) and then run from command line on the other machines... command would be something like "java YourProgram" and see what it does... does it still say Main not found?

    im unsure how complex your project is, and if you have multiple source files generated now (.java files) or if you only have a single source file. if a single source file, you should be able to complile to .class and then run from command line... if u have multiple source files, then I'm probably of no help lol.

  5. #5
    SnakeDoc is offline Senior Member
    Join Date
    Apr 2012
    Posts
    129
    Rep Power
    0

    Default Re: Confused with JAR Files.

    Ok, another thing to try if you have not already. this will confirm if you file was formatted as an applet -

    create a html document such as this:

    <applet code="YourAppName.class" height=500 width=500></applet>

    Then place ur .class file as well as ur HTML file into the same directory, and run the HTML file using appletviewer

    command line code: appletviewer YourAppName.html

    this is used only for testing and shouldn't be used to run an applet otherwise... but may shed some light on how your app is working. Also, inspect your code in Eclipse, have you confirmed you have a main() block after Eclipse has messed with your code? Do you have an init() and paint() blocks? Those would confirm Eclipse turned your project into an applet.

    Hope this is of some help :-/

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: Confused with JAR Files.

    An applet extends one of the applet classes. An applet would not start execution by clicking on a jar file.

    To see if there is an error message that is not showing, open a command prompt window, change to the folder with jar file and enter the command:
    java -jar <THEJARFILENAME>.jar

    To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Please Help! I'm Confused.
    By teekei in forum New To Java
    Replies: 1
    Last Post: 10-25-2011, 05:26 AM
  2. Help Please - I'm confused
    By NextToNothing in forum Threads and Synchronization
    Replies: 4
    Last Post: 07-04-2011, 11:37 PM
  3. Confused :?
    By jESTPHROSTY in forum New To Java
    Replies: 2
    Last Post: 10-17-2010, 07:38 PM
  4. Very confused Plz help!!
    By ratb0y in forum NetBeans
    Replies: 0
    Last Post: 02-14-2009, 04:34 PM
  5. Confused
    By coldfire in forum New To Java
    Replies: 3
    Last Post: 01-13-2009, 01:00 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
  •