Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ilifecomputer

macrumors 6502
Original poster
Feb 9, 2005
391
100
CA
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.
 

ilifecomputer

macrumors 6502
Original poster
Feb 9, 2005
391
100
CA
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...
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
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
 

ilifecomputer

macrumors 6502
Original poster
Feb 9, 2005
391
100
CA
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.
 

ilifecomputer

macrumors 6502
Original poster
Feb 9, 2005
391
100
CA
<applet mayscript="yes" height="100%" width="100%" code="CaseApplet.class" archive="Numbs.jar">
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
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
 

Manty

macrumors member
Mar 18, 2008
32
0
Lisbon, Portugal
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
 

ManWithhat

macrumors regular
Jun 24, 2008
220
0
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;
      }
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.