how to determine if jar or class file is executable

Discussion in 'Java' started by kaith, Aug 15, 2003.

  1. kaith

    kaith Guest

    How can I determine if a particular class file/jar file is directly
    executable, meaning it has a main etc.
     
    kaith, Aug 15, 2003
    #1
    1. Advertising

  2. kaith

    Roedy Green Guest

    On 15 Aug 2003 14:45:16 -0700, (kaith) wrote or
    quoted :

    >How can I determine if a particular class file/jar file is directly
    >executable, meaning it has a main etc.


    You can read and parse the manifest. It is just a text file entry. I
    don't know of a more direct way. It still won't necessarily execute.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Aug 16, 2003
    #2
    1. Advertising

  3. Roedy Green <> wrote in message news:<>...
    > On 15 Aug 2003 14:45:16 -0700, (kaith) wrote or
    > quoted :
    >
    > >How can I determine if a particular class file/jar file is directly
    > >executable, meaning it has a main etc.

    >
    > You can read and parse the manifest. It is just a text file entry. I
    > don't know of a more direct way. It still won't necessarily execute.


    To read the manifest use

    http://java.sun.com/j2se/1.4.2/docs/api/java/util/jar/JarFile.html#getManifest()

    For the class you could use reflection to see is a method

    public static void main(String[] args)

    is present.
     
    Sandip Chitale, Aug 16, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. cyril
    Replies:
    2
    Views:
    3,947
    cyril
    Aug 25, 2004
  2. Arnold Peters
    Replies:
    0
    Views:
    631
    Arnold Peters
    Jan 5, 2005
  3. muttley
    Replies:
    0
    Views:
    2,791
    muttley
    Oct 20, 2005
  4. cyberco
    Replies:
    4
    Views:
    3,868
    Roedy Green
    Feb 14, 2006
  5. Jason Cavett
    Replies:
    8
    Views:
    657
    Sanjay
    May 16, 2007
Loading...

Share This Page