Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2011
    Location
    India
    Posts
    67
    Rep Power
    0

    Default .exe file in CUI applications in java

    sir i have a small doubt.
    class sample
    {
    public static void main(String args[])
    {
    System.out.println("Hai");
    }
    }
    after creating the java program,
    we just compile it using: javac sample.java
    after compiling java program we get .class file and it was stored in current working directory or folder.
    after that we run the java program: java sample
    after it creates the .exe file right? but i didnt found the .exe file in my folder?
    How i can get it?
    please send me quick reply...


    thank you!!!!!

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,375
    Blog Entries
    7
    Rep Power
    20

    Default Re: .exe file in CUI applications in java

    Quote Originally Posted by chandrasekhar.melam View Post
    after that we run the java program: java sample
    after it creates the .exe file right?
    Nope, the java.exe command starts the JVM and runs your .class file; no .exe file is created, nor is it involved in the process.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Join Date
    Sep 2011
    Location
    India
    Posts
    67
    Rep Power
    0

    Default Re: .exe file in CUI applications in java

    but in c or c++ languages create the .exe files right?
    but why java doesnt creates?
    will you explain?

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,375
    Blog Entries
    7
    Rep Power
    20

    Default Re: .exe file in CUI applications in java

    Quote Originally Posted by chandrasekhar.melam View Post
    but in c or c++ languages create the .exe files right?
    but why java doesnt creates?
    will you explain?
    Because in Java you can carry your .class file to a, say, Sun Solaris box, a Linux box, an IBM AS/400 box, without recompilation, and it runs! .exe files only have a meaning on a MS Windows box.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,856
    Rep Power
    19

    Default Re: .exe file in CUI applications in java

    Because Java creates byte code, and the JVM interprets and runs that.
    C etc compile to stuff that's closer to the metal, and so are run by the OS directly.

    Because Java doesn't do that code that is compiled to .class files can run on any OS with a compatible JVM...unlike the C code which would need to have an OS specific compilation done.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,856
    Rep Power
    19

    Default Re: .exe file in CUI applications in java

    Or put another way...what Jos said.

Similar Threads

  1. using SSL in java applications
    By porchrat in forum Advanced Java
    Replies: 4
    Last Post: 06-28-2011, 01:15 PM
  2. See the Policy File Effects (Applications)
    By Lil_Aziz1 in forum New To Java
    Replies: 3
    Last Post: 06-06-2010, 06:11 AM
  3. Replies: 3
    Last Post: 01-29-2010, 06:53 AM
  4. Deploying java applications.
    By J-Live in forum New To Java
    Replies: 7
    Last Post: 11-24-2008, 07:08 AM
  5. convert VB6 applications to Java
    By bbq in forum New To Java
    Replies: 1
    Last Post: 07-05-2007, 03:57 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
  •