Find the answer to your Linux question:
Results 1 to 7 of 7
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2004
    Location
    Syria
    Posts
    9

    Java compiling!!!!


    Hello there

    I was wondering how can I compile a Java code in RedHat!!!
    you know in C I write
    gcc <filename> ... to compite it
    ./a.out ................. to see the out put...

    thx for your time....

  2. #2
    Just Joined!
    Join Date
    Jan 2004
    Location
    Portugal
    Posts
    93
    try
    Code:
    javac file.class

  3. #3
    Linux User
    Join Date
    Jul 2004
    Location
    Poland
    Posts
    368
    Of course, you have to have Java SDK (software developement kit) installed and configured in order to be able to compile anything.
    "I don't know what I'm running from
    And I don't know where I'm running to
    There's something deep and strange inside of me I see"

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Enthusiast
    Join Date
    Jun 2002
    Location
    San Antonio
    Posts
    621
    Also, you don't compile class files. You compile java files into class files. That would be like putting toast into a toaster.

    Code:
    javac TestClass.java
    Will compile the java file into TestClass.class (assuming the java file contained the line "class TestClass"). You can then run:
    Code:
    java TestClass
    so long as the TestClass.java file has a main() function defined

    Best,

    Samuel
    I respectfully decline the invitation to join your delusion.

  6. #5
    Just Joined!
    Join Date
    Jan 2004
    Location
    Portugal
    Posts
    93
    That's right, sorry for the mix-up....

    but since we're on the topic of java:

    How do you compile into .jar ??
    What are the diferences to compiling to .class? (besides the number of files=)

  7. #6
    Linux Enthusiast
    Join Date
    Jun 2002
    Location
    San Antonio
    Posts
    621
    You don't compile into a jar. You compile a bunch of class files into a directory heirarchy. Then you zip them up into a jar. That's right, jar is just zip. Try it sometime. 'unzip /usr/local/jdk1.3.1/demo/jpda/examples.jar'.

    Best,

    Samuel
    I respectfully decline the invitation to join your delusion.

  8. #7
    Just Joined!
    Join Date
    Oct 2004
    Location
    Syria
    Posts
    9

    THX!

    Thank you all for the help!



    Have great time!

    ZTH

Posting Permissions

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