How do i compile Java in OSX?

Discussion in 'Mac Apps and Mac App Store' started by jethroted, Jun 4, 2003.

  1. jethroted macrumors 6502a

    jethroted

    Joined:
    Jan 2, 2003
    Location:
    Cyberspace
    #1
    I downloaded an app in java source code. There was no binary. I have no idea what to do with it. I'm not big into programing, source codes, and the like.

    *zips up fire proof suit*

    Please be gentle. ;)
     
  2. mnkeybsness macrumors 68030

    mnkeybsness

    Joined:
    Jun 25, 2001
    Location:
    Moneyapolis, Minnesota
    #2
    you'll need a java program compiler. i use codewarrior, but you can try getting something free like bluej from www.versiontracker.com
     
  3. szark macrumors 68030

    szark

    Joined:
    May 14, 2002
    Location:
    Arid-Zone-A
    #3
    You should also be able to use Apple's Developer Tools to compile it.
     
  4. jethroted thread starter macrumors 6502a

    jethroted

    Joined:
    Jan 2, 2003
    Location:
    Cyberspace
    #4
    I don't mean to sound stupid, but i need to know what to do, not just what to use.
     
  5. physicsnerd macrumors member

    Joined:
    Feb 25, 2003
    Location:
    West Lafayette, IN
    #5
    Okay, here's what you do.

    1st, you've got to find the main file. Sometimes it's labeled main, or the name of the program. It will be a .java file. Go in to terminal, and go to the file.

    Then once you've found the file you type:
    javac <filename.java>

    This will create a .class file in the same directory as the .java file you compiled.

    Then type java filename (do not put .class or .java after it).

    This should complie and run the program. Let me know if you have any problems.

    Physicsnerd
     
  6. jethroted thread starter macrumors 6502a

    jethroted

    Joined:
    Jan 2, 2003
    Location:
    Cyberspace
    #6
    There are a whole bunch of .java file though. That's the majority of the content. If you want to look at the source check it out here.

    I downloaded the jtella-07.zip file.
     
  7. physicsnerd macrumors member

    Joined:
    Feb 25, 2003
    Location:
    West Lafayette, IN
    #7
    from the readme:

    This is not a program like you think it is. This is an API. What these files let you do is write programs that can access the different fuctions of GNUTella. However, it is not a GNUTella client. Atleast it doesn't look to be. Can anyone verify my conclusion?

    Physicsnerd
     
  8. jethroted thread starter macrumors 6502a

    jethroted

    Joined:
    Jan 2, 2003
    Location:
    Cyberspace
    #8
    My brother was telling me i needed a .jar file. What do i need that for? There is one of those in the folder.
     
  9. szark macrumors 68030

    szark

    Joined:
    May 14, 2002
    Location:
    Arid-Zone-A
    #9
    Agreed. This is not a self-contained program.

    You would need to write a java program to use the source code you downloaded.
     
  10. jethroted thread starter macrumors 6502a

    jethroted

    Joined:
    Jan 2, 2003
    Location:
    Cyberspace
    #10
    What? I need to write a program to use the source code? So I can't use this stuff at all with out doing that?
     
  11. zimv20 macrumors 601

    zimv20

    Joined:
    Jul 18, 2002
    Location:
    toronto
    #11
    well, you could find a program someone else wrote to use the library, but in general, yes.

    a jar is simply a collection of pre-compiled java files. it's akin to a unix .so library or (the dreaded) windows .dll.

    like those, you put the jars in a known place and direct your java environment to that place (i think the environment variable is JARPATH, but i haven't done any java in 4 years).

    i recommend buying a java book and doing some reading. (sorry, i have no recommendations on which book)
     
  12. jethroted thread starter macrumors 6502a

    jethroted

    Joined:
    Jan 2, 2003
    Location:
    Cyberspace
    #12
    OK, so the .jar file is pre compiled. So that should be ready to run then? Or do I have to do something with it to get it ready to run?
     
  13. zimv20 macrumors 601

    zimv20

    Joined:
    Jul 18, 2002
    Location:
    toronto
    #13
    as long as the program you're running (the one you don't have yet) knows where it is, you're good to go.
     
  14. jethroted thread starter macrumors 6502a

    jethroted

    Joined:
    Jan 2, 2003
    Location:
    Cyberspace
    #14
    Oh man, I give up. Why didn't they just have the binary there? This is ridiculous, I thought compiling was as simple as taking your source code, then running it through a compiler, and then you get your binary file. That makes sense to me.
     
  15. zimv20 macrumors 601

    zimv20

    Joined:
    Jul 18, 2002
    Location:
    toronto
    #15
    the jar _is_ the "binary."

    errrr.... it is that simple. except when you're sharing code across executables, then you need to get into libraries (jarfiles, in the case of java).

    and the added complexity that java runs in a virtual machine. but that complexity shouldn't affect you (since you're not writing something on the magnitude of a compiler).

    buy a book. start small.
     
  16. jethroted thread starter macrumors 6502a

    jethroted

    Joined:
    Jan 2, 2003
    Location:
    Cyberspace
    #16
    I guess that is what i'll have to do, although i didn't really want to get into programing, I just wanted to run an app. I realize they released the source code so developers could work on it, but they should have released an executable file as well so people who just want to run the app could do so.
     
  17. zimv20 macrumors 601

    zimv20

    Joined:
    Jul 18, 2002
    Location:
    toronto
    #17
    but i thought it was a library you d/loaded, not an app.

    also, if you're gonna muck about on the command line and d/loading source code, you will have to deal w/ some of the same things programmers do. like the non-trivial world of make
     
  18. Thom_Edwards macrumors regular

    Joined:
    Apr 11, 2003
    #18
    as has been stated above, you didn't download an app. there is nothing to run, nor can there be. you downloaded an extension, or Application Programming Interface (API), that allows you to program with more features (objects, methods).

    here's a WAY out there example....

    you're writing the matrix, and you have a human named Guy New that you need to create. in the existing matrix code (java) there is no way to make Guy move. so, you download a human api that includes the ability for a human move. now you can use... humanGuyNew.Move()
    where you couldn't before you had this api you downloaded.

    also, i saw a post earlier about javac. you actually should run javac at the same directory level as the directory that contains the .java files. example--navigate to the directory that is at the same level as this directory, then type...

    javac directory/filename.java
     
  19. Taft macrumors 65816

    Taft

    Joined:
    Jan 31, 2002
    Location:
    Chicago
    #19
    The problem here is that you don't understand the basic concepts of what a program is. Read the following very carefully...

    What you downloaded was NOT an application or even the source to an application. You downloaded a bunch of code that other applications can use. This is often called an API, or a library, or a .dll, etc. Think of it as a bunch of compiled code that other applications can run. As an example, Cocoa is an API similar to this application. It provides Mac OS X programmers a bunch of code which makes creating GUI's much easier.

    Second, the code you downloaded wasn't packaged very well. There was no makefile or ANT script or any other device to easily compile the code or run it. This isn't your fault: the prorammers are to blame. Even if this was code you wanted (you don't want it, by the way), there wouldn't have been an easy way to compile/install/run it.

    Taft
     
  20. jethroted thread starter macrumors 6502a

    jethroted

    Joined:
    Jan 2, 2003
    Location:
    Cyberspace
    #20
    Sorry for being so dense. I really know nothing about programing. I did some gw basic back in high school, and that's about it. I get it now though. Thanks for your help guys.
     

Share This Page