Results 1 to 9 of 9
  1. #1
    ReclaimerGold is offline Member
    Join Date
    Apr 2011
    Location
    South Dakota, United States
    Posts
    4
    Rep Power
    0

    Post Is it possible to use an external program to run a .class file?

    Im trying to run my program from startup, but Im having trouble converting it into a jar. I was wondering if there was an external program that could 'compile/run' my program in a window, instead of having to open my editor (JCreator LE) and compile it to use it. Any Suggestions, or help would be greatly appreciated :), and advice on how to convert my program to jar would be helpful too!

  2. #2
    f1gh is offline Member
    Join Date
    Nov 2010
    Posts
    46
    Rep Power
    0

    Default

    if you installed the jdk on your computer open up the windows command prompt
    navigate to the directory where your java source code file is.
    to compile this file:

    javac yourfile.java

    To run this file from command prompt (note if you use the above command to compile the java source code it will place the byte code file in the same directory as the source code file)

    java yourfile

    Note when running the file you do not give the ending extension.

    Hope this helps.

    Also if you are starting out with java development I would advise using NetBeans or Eclipse as those are the best and most popular java ide's.

  3. #3
    ra4king's Avatar
    ra4king is offline Senior Member
    Join Date
    Apr 2011
    Location
    Atlanta, Georgia, US
    Posts
    396
    Rep Power
    4

    Default

    @f1gh
    That does not answer the OP's question at all. He wants a graphical tool to compile, run, and make a Jar file.

    @OP
    I do not believe there is a tool that can do this for you. The only ways that I know are possible is to run "javac", "java", and "jar" in the command line or using your IDE's tools.
    Last edited by ra4king; 04-29-2011 at 01:15 AM.

  4. #4
    f1gh is offline Member
    Join Date
    Nov 2010
    Posts
    46
    Rep Power
    0

    Default

    @ra4king before you bother opening your mouth pay attention to what the op is asking:
    I was wondering if there was an external program that could 'compile/run' my program in a window, instead of having to open my editor (JCreator LE) and compile it to use it
    and than he goes onto ask also how he could make a jar which i didn't answer as i use netbeans to do all that i know its possible to do it using javac but i don't remember the cmd off top of head and don't want to use google to find out at moment.

    And also since you didn't ask the question, You should leave it to the OP whether i have answered his question or not. When you ask and i answer than you can tell me, UNDERSTOOD?

  5. #5
    ra4king's Avatar
    ra4king is offline Senior Member
    Join Date
    Apr 2011
    Location
    Atlanta, Georgia, US
    Posts
    396
    Rep Power
    4

    Default

    Not the jar part. He said he wants a graphical tool not the command line. I just forgot to add the part about javac and java.

  6. #6
    ReclaimerGold is offline Member
    Join Date
    Apr 2011
    Location
    South Dakota, United States
    Posts
    4
    Rep Power
    0

    Default

    Both of you helped alot, ive attempted to use cmd to write my .class files into a jar file, but the only problem is it writes a default manifest, and when i try to edit it to declare what the main class is( so that when the jar is run, it compiles the main) it doesn't save to the META-INF folder, so it doesn't access the right .mf file... sorry if im confusing

  7. #7
    ra4king's Avatar
    ra4king is offline Senior Member
    Join Date
    Apr 2011
    Location
    Atlanta, Georgia, US
    Posts
    396
    Rep Power
    4

    Default

    You are able to specify your own manifest file by using the -m option:
    Java Code:
    jar -cmf manifest.txt MyJar.jar MyClass.class
    On a side note, I'm quite astounded that you'd rather use the command line than the faster/easier built-in tools in any IDE. Using the command line is mainly if you want to learn and understand how it all works behind the scenes.

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

  9. #9
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Quote Originally Posted by f1gh View Post
    java yourfile

    Note when running the file you do not give the ending extension.

    In fact you are running (invoking the main() method of) a class not a file. Which is why there is no .java unless you have a very weirdly named class. The full name of the class is used (package and all).

Similar Threads

  1. called external program does not automatically write file
    By nickvandewiele in forum New To Java
    Replies: 6
    Last Post: 02-25-2010, 02:38 PM
  2. Execute external file/program
    By sirwiggles in forum New To Java
    Replies: 3
    Last Post: 04-21-2009, 11:35 PM
  3. Replies: 0
    Last Post: 04-04-2008, 02:40 PM
  4. Replies: 0
    Last Post: 10-04-2007, 09:33 PM
  5. Use a external file in my program
    By romina in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 05:28 AM

Posting Permissions

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