Novice looking for very basic Java information

Discussion in 'Mac Programming' started by ilifecomputer, Jul 17, 2008.

  1. ilifecomputer macrumors 6502

    Joined:
    Feb 9, 2005
    Location:
    Los Angeles, CA
    #1
    Hey all,

    I am about to embark on a project for my advisor at school which is essentially to figure out what is going on with a web applet that was put into a basic website. The website loads but the program doesn't load in its table, instead you can see all the java code.

    More information: I've decided to take this project seriously and look more into learning Java (I have some programming skills but many years back on a windows environment; Now on a mac) What I really want to know is what program should I be using to write and execute code? After browsing and searching forums, I think using the terminal is somehow involved? I really do not know what I need to start practicing more.

    Text edit and a compiler? Any suggestions on the applet not showing up? Any good books that detail the process on Mac OS?

    If anyone can suggest anything or help me out I would greatly appreciate it. Thanks.
     
  2. ilifecomputer thread starter macrumors 6502

    Joined:
    Feb 9, 2005
    Location:
    Los Angeles, CA
    #2
    Ok. So I figured out step one was getting Xcode as an IDE. Will look into starting my code there and let you guys know how it goes...
     
  3. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #3
    This sounds like an error in the syntax used to include the applet on the page. It should look something like:
    Code:
    <applet code="MyGreatJavaClass.class" height=200 width=320>
    They probably have this currently, or something like it referring to the .java file:
    Code:
    <applet code="MyGreatJavaClass.java" height=200 width=320>
    If it's bytecode showing up and not the java code, that would be some other interesting permutation.

    -Lee
     
  4. ilifecomputer thread starter macrumors 6502

    Joined:
    Feb 9, 2005
    Location:
    Los Angeles, CA
    #4
    Ok, will look at that specifically and thanks a whole lot for the suggestion. It will help. Yea, and definitely showing the java code. Thanks, again.
     
  5. ilifecomputer thread starter macrumors 6502

    Joined:
    Feb 9, 2005
    Location:
    Los Angeles, CA
    #5
    <applet mayscript="yes" height="100%" width="100%" code="CaseApplet.class" archive="Numbs.jar">
     
  6. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #6
    The applet tag looks OK. I just jar'd up the class file I was testing with, and used the same syntax without issue. Is Numbs.jar in the same directory as the HTML file that is loading it? What are the contents of Numbs.jar (jar -tvf Numbs.jar will show you the contents)?

    What exactly displays in the browser? Something like:

    Code:
    ...
    import java.applet.Applet;
    ...
    public class CaseApplet extends Applet {
    ...
    ?

    -Lee
     
  7. Manty macrumors member

    Joined:
    Mar 18, 2008
    Location:
    Lisbon, Portugal
    #7
    I think the best IDE that you can use to code in Java is Intellij IDEA, but it's expensive. Xcode is a pretty good IDE too once you get used to it.


    Manty
     
  8. Kisto macrumors newbie

    Joined:
    Nov 4, 2008
    #8
    Searching on array.

    How can I search the the number enter by user?
     
  9. ManWithhat macrumors regular

    Joined:
    Jun 24, 2008
    #9
    As in the number entered by a user?

    Code:
    	
    String [] someArray = new String [10];
    Scanner userIn = new Scanner( System.in );
    int indexNum = userIn.nextInt();
    System.println( someArray[indexNum] );
    
    /shrug
    That's making a few assumptions . . but it's the jist.
    It might be different depending on whether you're using an Array or ArrayList object.

    If you're talking about finding a number a user entered in an array:
    Code:
    	
    bool found = false;
    int foundAtIndex;
    int [] someArray = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    Scanner userIn = new Scanner( System.in );
    int searchNum = userIn.nextInt();
    for(int i = 0; i < someArray.length; i++)
    {
          if ( i == searchNum )
          {
               found = true;
               foundAtIndex = i;
               break;
          }
    }
    
    
     

Share This Page