Results 1 to 3 of 3
  1. #1
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default Executing .class files on Windows with a double click or right click

    Use the Windows Explorer Tools|Folder Options|File Types menu to add this command line for a .class file:

    C:\BatchFiles\ExecClass.bat "%1"

    Change the path and folder to where you put the ExecClass.bat file.

    The ExecClass.bat file:

    Java Code:
    REM Execute a java class file - need to strip extension
    echo filename is %~n1
    java %~n1
    MORE
    The trick here is that the %~n1 variable returns the filename only. The java command doesn't like the .class extension which you would get with the normal %1

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,236
    Rep Power
    19

    Default

    Would that work for a class in a package? I guess not.

    Also, did you mean to post this as a blog?

    db

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

    Default

    Good point.
    No it wouldn't. I use it for the simple test programs I make to answer questions for students on forums. I always strip off the package statement.

Similar Threads

  1. Executing a jar double-click style in Linux
    By goodwillwins in forum AWT / Swing
    Replies: 24
    Last Post: 03-19-2011, 04:56 AM
  2. Double click event
    By Dipke in forum New To Java
    Replies: 3
    Last Post: 10-22-2010, 11:39 AM
  3. Double click eevent on particular row
    By selva.bics in forum AWT / Swing
    Replies: 3
    Last Post: 10-10-2009, 10:33 AM
  4. Run Jar file on double click
    By dhaval.rajput.p in forum New To Java
    Replies: 2
    Last Post: 07-24-2009, 05:44 PM
  5. How to detect double click with a JFrame
    By Jary316 in forum New To Java
    Replies: 3
    Last Post: 01-05-2009, 08:39 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
  •