java and xcode 3

Discussion in 'Mac Programming' started by twoodcc, Jan 7, 2008.

  1. twoodcc macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #1
    so, i'm taking a java class. i created a new java application project in xcode 3, but where if the .java file?
     
  2. Amigori macrumors newbie

    Joined:
    May 2, 2005
    Location:
    Toledo, OH
    #2
    Here's a few places to check:

    ~/$ProjectName
    /Users/$HomeDir/$ProjectName (same dir as above, just the full structure)
    /Developer/$ProjectName

    Within XCode, you can press Apple+I and it will show where its at.
    e.g "Path: /Users/$HomeDir/Projects/$ProjectName"
     
  3. twoodcc thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #3
    thanks, but i mean inside xcode. i thought that it would be there, but it's not. i only see a .xml file, and some folders, but no .java file

    did i do something wrong? i just chose a Java application when i created a new project
     
  4. jsw Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #4
    No problem... you've created the project, but no file.

    When you're looking at the project window, right click on the project (should be the top thing under "Groups and Files" on the left) and select Add->New File...->Pure Java->Java Class.
     
  5. twoodcc thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #5
    oh ok. i thought it was something like that. i'm used to other languages, where xcode makes though files automatically
     
  6. jsw Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #6
    The thing is, there's no automatic file it could make, unless you'd be willing to assume that a "MySampleProject" project would always want "MySampleProject.java", which is possibly useful for school projects, but which a professional would rarely want.
     
  7. twoodcc thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #7
    oh ok. well, java is still very new to me (first day of class). hopefully i'll learn more very soon

    thanks :)
     
  8. twoodcc thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #8
    ok, so i'm having a little trouble. i made a new project - a java application. did i want java applet?

    i added the java class file to it. but all i want is a simple command line program. what i have doesn't print anything.
     
  9. toddburch macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #9
    No, you didn't want a java applet, unless you will be embedding it into a web page.

    You probably wanted a Java Tool. With a Tool, it does build a .java file template for you with a "Hello World!" println.

    Todd
     
  10. twoodcc thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #10
    thanks, i'll try that next time.

    i ended up just using terminal to compile and run the program. i made a 100! :D
     
  11. toddburch macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #11
    WOO-HOO!!! Good for you. What was the assignment?
     
  12. twoodcc thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #12
    thanks. it wasn't hard. 3 very simple programs:

    1. make a program that flips a coin 10 times and displays heads or tails
    2. change program #1 to ask the user how many times to flip the coin
    3. put 100 random numbers in an array. print the sum of the square roots of the values.

    so it was pretty easy. but i know they'll get harder
     
  13. twoodcc thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #13
    so for my class, we will be creating java servlets. in windows, they use tomcat. what do i use for mac and with xcode? or can i do this?
     
  14. Wes macrumors 68020

    Wes

    Joined:
    Jun 22, 2001
    Location:
    London
    #14
    Tomcat works on Mac OS also. When I worked with JSP I used used a text editor like TextWrangler and the terminal.
     
  15. jeremy.king macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #15
    twoodcc, thanks for demonstrating why an IDE may not make sense when getting started with Java and congrats on your 100. If you really wanted to try an IDE again later that shouldn't get in the way, do check out Netbeans BlueJ edition.

    Also, you can use a variety of app servers such as tomcat, jetty, glassfish and others...All work just as well on the Mac. I'd suggest tomcat since that's what the instructor is using.
     
  16. Monkaaay macrumors 6502

    Monkaaay

    Joined:
    Jun 19, 2006
    Location:
    Richmond, VA
    #16
    Just because he doesn't understand the concept of an IDE before it ever being explained to him doesn't make your statement correct. Spend 5 minutes, explain the differences of these tools, and he'll be off on his merry way with more knowledge.
     
  17. twoodcc thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #17
    thanks, i'm working on installing tomcat now. a little more complex than i thought

    thanks, i actually made 100 last week, and the instructor asked me to present it to the class! again, it was still just a simple program.

    yeah, i'll go with tomcat since my team members have that as well. i also have to think about what type of database to use. mysql?
     
  18. jeremy.king macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #18
    Again, lots of choice here. I suggest you use what your instructor encourages. You can use Mysql no problem.
     
  19. twoodcc thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #19
    well, he said you could any you wanted to, but recommended access. which i can't do i mac os x, right?

    also, i'm having trouble installing tomcat. i was trying to go by apple's pdf, but for some reason it didn't work
     
  20. osxfactor macrumors newbie

    Joined:
    Feb 8, 2008
    #20
    Java, Mac OS X, and IDEs

    Congrats on the good score. I'm taking a couple of Java classes now myself (just finishing up the first one).

    A few things to note when developing Java apps on Mac OS X.

    1) XCode is nice, but Eclipse is a much better Java IDE (although I feel that Xcode is a much better IDE overall). Especially for a newbie like you and me, Eclipse is always compiling and evaluating code, and it will let you know immediately when you've made a mistake, which is much better than writing 100 lines of code and finding your mistake after your run your app. TextMate makes a pretty nice code editor as well, but still, you don't get the instant code checking that Eclipse provides.

    2) There are plenty of servlet engines for Mac OS X. Tomcat is the most popular. The installation is pretty painless. Download it, unzip it, place it in your apps folder, and then run the catalina.sh start script in the terminal. Boom. Check localhost:8080, and you should see the Tomcat splash screen. There is also JBoss, and now Glassfish as well.

    3) Get comfortable with the command line. Compiling from the command line is easy once you know what you are doing. Most Java tools are written with UNIX/Linux in mind, so using the terminal will be a huge help to you down the road.

    Good luck!
     
  21. twoodcc thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #21
    thanks for the nice post.

    where can i download that tomcat? i did download one version, but i had to compile it myself somehow, and i couldn't do it right
     
  22. jeremy.king macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #22
  23. twoodcc thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #23
  24. jeremy.king macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #24
    First try to start tomcat without doing that. If it launches, you won't need to. If it complains that you should set JAVA_HOME, in terminal
    Code:
    setenv JAVA_HOME /System/Library/Frameworks/JavaVM.framework/Home
    You can also add the above command to your .bashrc file located in your home folder. If you don't have that file, you can create it.
     
  25. twoodcc thread starter macrumors P6

    twoodcc

    Joined:
    Feb 3, 2005
    Location:
    Right side of wrong
    #25
    well i'm still confused. i downloaded the zip, and unzipped it. now i have a folder with files in it, but nothing to launch/start tomcat (that i see).

    i tried your command in terminal, but it said "setenv: command not found"

    sorry i'm new to the command line
     

Share This Page