Running from a Website

Hey,Can someone point me to a tutorial or give me a step by step guide on getting my game from working in JCreator to working on a website? How would I do this? Thanks.
[182 byte] By [GilGalvantia] at [2007-11-27 8:02:34]
# 1
Depends on what you've used to create your game.You'll likely want to make sure the game is a Java Applet, so you might want to look at the Java Tutorial on Applets. That would be a good place to start.b.
bryanoa at 2007-7-12 19:44:44 > top of Java-index,Java Essentials,New To Java...
# 2
Is your game an applet, or is it a web application? Or something else?
DrLaszloJamfa at 2007-7-12 19:44:44 > top of Java-index,Java Essentials,New To Java...
# 3
I've never seen a website with legs, it shouldn't be too hard to run from.
hunter9000a at 2007-7-12 19:44:44 > top of Java-index,Java Essentials,New To Java...
# 4
Well it extends Applet, so I guess that means it's an applet :P. Heh, sorry, I'm really new to all of this.
GilGalvantia at 2007-7-12 19:44:44 > top of Java-index,Java Essentials,New To Java...
# 5
Discuss: What's the last web site you ran from?
DrLaszloJamfa at 2007-7-12 19:44:44 > top of Java-index,Java Essentials,New To Java...
# 6
> Discuss: What's the last web site you ran from?I went to foxnews.com a while back, that was pretty horrifying.
hunter9000a at 2007-7-12 19:44:44 > top of Java-index,Java Essentials,New To Java...
# 7
Anyone know of any tutorials for this? I have no idea what to do and this is fairly urgent.
GilGalvantia at 2007-7-12 19:44:45 > top of Java-index,Java Essentials,New To Java...
# 8
> Anyone know of any tutorials for this? I have no idea> what to do and this is fairly urgent.Tutorials for running from foxnews, or for answering the question of if your game's an applet?
hunter9000a at 2007-7-12 19:44:45 > top of Java-index,Java Essentials,New To Java...
# 9
I don't think I need one on running from foxnews ;).Java is beginning to frustrate me with it's unnecessary complexity.
GilGalvantia at 2007-7-12 19:44:45 > top of Java-index,Java Essentials,New To Java...
# 10

> I don't think I need one on running from foxnews ;).

>

> Java is beginning to frustrate me with it's

> unnecessary complexity.

You can quit at anytime. If you don't want to do quit, why don't you ask a specific question about the problem you're having?

hunter9000a at 2007-7-12 19:44:45 > top of Java-index,Java Essentials,New To Java...
# 11

I don't want to quit, and I can't, really. I'm just used to basic where you can have a 3D rotating cube on the screen in 4 lines, and here it takes more than that just to set up the simplest possible thing that will compile. I'm needing to eventually get some games up on websites, so I'm wondering how I would do that exactly. I have no idea where to even start, so that's what I'm asking.

GilGalvantia at 2007-7-12 19:44:45 > top of Java-index,Java Essentials,New To Java...
# 12

> I don't want to quit, and I can't, really. I'm just

> used to basic where you can have a 3D rotating cube

> on the screen in 4 lines, and here it takes more than

> that just to set up the simplest possible thing that

> will compile. I'm needing to eventually get some

> games up on websites, so I'm wondering how I would do

> that exactly. I have no idea where to even start, so

> that's what I'm asking.

I'd like to see a rotating 3D cube with 4 lines of basic code ;-)

Java is a good way to go. Applets are what you want to look at but Java is a super complex language because it is super powerful and can be used to do just about anything.

I'd suggest looking at the AWT/Swing tutorial and Applet tutorial on the Sun web site as a starting point.

But Java it isn't a language many people can just dive right into and start writing games / apps right from the get go.

bryanoa at 2007-7-12 19:44:45 > top of Java-index,Java Essentials,New To Java...
# 13

> Java is beginning to frustrate me with it's

> unnecessary complexity.

How did you find out its complexity is "unnecessary" ?

I personally didn't find anything unnecessary or illogical in Java after a few years of developing. Java is very powerful as it is complex. It's designed "by professional programmers FOR professional programmers", not for kids who want to play with it, or creating a rotating cube in 4 lines.

Arash.Shahkara at 2007-7-12 19:44:45 > top of Java-index,Java Essentials,New To Java...
# 14

> I'd like to see a rotating 3D cube with 4 lines of

> basic code ;-)

>

> Java is a good way to go. Applets are what you want

> to look at but Java is a super complex language

> because it is super powerful and can be used to do

> just about anything.

>

> I'd suggest looking at the AWT/Swing tutorial and

> Applet tutorial on the Sun web site as a starting

> point.

>

> But Java it isn't a language many people can just

> dive right into and start writing games / apps right

> from the get go.

Okay, here's the basic code, I'm serious, 4 lines ;).

make object cube 1, 5

DO

yrotate object 1, object angle y( 1 ) + 1

LOOP

Here's even a video of a game I'm making in it, which is currently 6000 lines.

http://www.youtube.com/watch?v=CBmZ7OzFZwE

I don't plan on diving right in, I learned it in school this year (if you could call it that, mostly self-taught, the course sucked), and am trying to learn more this summer. All I want is a simple app up on a website. I'm not trying to get the next World of Warcraft on an applet ;).

GilGalvantia at 2007-7-12 19:44:45 > top of Java-index,Java Essentials,New To Java...
# 15
That's why I suggested the AWT/Swing and Applet tutorials. Perfect place to start gathering knowledge about the language with respect to applets / web based applications.
bryanoa at 2007-7-21 22:28:23 > top of Java-index,Java Essentials,New To Java...
# 16

> > Java is beginning to frustrate me with it's

> > unnecessary complexity.

>

> How did you find out its complexity is "unnecessary"

> ?

>

> I personally didn't find anything unnecessary or

> illogical in Java after a few years of developing.

> Java is very powerful as it is complex. It's designed

> "by professional programmers FOR professional

> programmers", not for kids who want to play with it,

> or creating a rotating cube in 4 lines.

Because, coming from basic, it has many unnecessary features that should be done for you. I'll make a quick list off the top of my head:

1) Why doesn't it default variables to 0 or null if you don't define them?

2) Why does it matter if a method is static and you reference a non-static method?

3) Why do you have to pass the graphics class into every method you want to use it in? Why can't it just be global?

4) Why doesn't java automatically import all needed classes and API's for you instead of you manually having to do it at the top?

5) Why do you need double equal signs to evaluate equality instead of a single one? Java should have the ability to realize which one you're wanting without problem like in basic.

6) Why do you need all the methods for something you implement such as MouseListener if you're not going to use them?

7) Why does all the input have to be defined to it's respective method? Why can't I say "if( mousePressed == true )" in the main method?

8) Why do you need a specific method to paint?

and that's just off the top of my head.

GilGalvantia at 2007-7-21 22:28:23 > top of Java-index,Java Essentials,New To Java...
# 17

> That's why I suggested the AWT/Swing and Applet

> tutorials. Perfect place to start gathering

> knowledge about the language with respect to applets

> / web based applications.

I've looked at some of them, but the one's I've found don't actually tell you how to get it on a web page, which is what I need. I already know how to make basic Applets using AWT, just not get them on the web.

GilGalvantia at 2007-7-21 22:28:23 > top of Java-index,Java Essentials,New To Java...
# 18

> > > Java is beginning to frustrate me with it's

> > > unnecessary complexity.

> >

> > How did you find out its complexity is

> "unnecessary"

> > ?

> >

> > I personally didn't find anything unnecessary or

> > illogical in Java after a few years of developing.

> > Java is very powerful as it is complex. It's

> designed

> > "by professional programmers FOR professional

> > programmers", not for kids who want to play with

> it,

> > or creating a rotating cube in 4 lines.

> Because, coming from basic, it has many unnecessary

> features that should be done for you. I'll make a

> quick list off the top of my head:

> 1) Why doesn't it default variables to 0 or null if

> you don't define them?

> 2) Why does it matter if a method is static and you

> reference a non-static method?

> 3) Why do you have to pass the graphics class into

> every method you want to use it in? Why can't it just

> be global?

> 4) Why doesn't java automatically import all needed

> classes and API's for you instead of you manually

> having to do it at the top?

> 5) Why do you need double equal signs to evaluate

> equality instead of a single one? Java should have

> the ability to realize which one you're wanting

> without problem like in basic.

> 6) Why do you need all the methods for something you

> implement such as MouseListener if you're not going

> to use them?

> 7) Why does all the input have to be defined to it's

> respective method? Why can't I say "if( mousePressed

> == true )" in the main method?

> 8) Why do you need a specific method to paint?

>

> and that's just off the top of my head.

Lol, that's like buying a tank to drive to the grocery store then complaining that all those guns and treads are unneccesary. They are if you're just going to the grocery store. But tanks are designed for much than that. You can program a computer to do almost anything it's capable of in java. Don't you think that requires a lot of complexity?

hunter9000a at 2007-7-21 22:28:23 > top of Java-index,Java Essentials,New To Java...
# 19

> Lol, that's like buying a tank to drive to the

> grocery store then complaining that all those guns

> and treads are unneccesary. They are if you're just

> going to the grocery store. But tanks are designed

> for much than that. You can program a computer to do

> almost anything it's capable of in java. Don't

> you think that requires a lot of complexity?

I see what you're trying to say, but I still think that most of those are unnecessary no matter the complexity of the program your creating. I'm not saying I think Java should be simpler, I'm just saying that it doesn't need many of the little things like the 8 I listed above. For example, why doesn't it automatically default variables to null or 0 if undefined? That way you wouldn't have to define every single variable in your program at the top. And why is passing Graphics g to everything you use it in necessary? Why can't they just make it where it's automatically there? Or get rid of it altogether, I don't see the point of even say "g."... Why not just "fillRect( x, y, width, height )"?

GilGalvantia at 2007-7-21 22:28:23 > top of Java-index,Java Essentials,New To Java...
# 20

> I see what you're trying to say, but I still think

> that most of those are unnecessary no matter the

> complexity of the program your creating. I'm not

> saying I think Java should be simpler, I'm just

> saying that it doesn't need many of the little things

> like the 8 I listed above. For example, why doesn't

> it automatically default variables to null or 0 if

> undefined? That way you wouldn't have to define every

> single variable in your program at the top.

Variables are assigned a default value if they're class members. If not, is it really that hard to add "= 0" to the end of the declaration?

> And why

> is passing Graphics g to everything you use it in

> necessary? Why can't they just make it where it's

> automatically there? Or get rid of it altogether, I

> don't see the point of even say "g."... Why not just

> "fillRect( x, y, width, height )"?

Because there can be many graphics contexts that you can draw on. There are images, the contents of components, etc. If you couldn't specify where to draw, it would severly limit what you could do.

hunter9000a at 2007-7-21 22:28:23 > top of Java-index,Java Essentials,New To Java...
# 21

> > I see what you're trying to say, but I still think

> > that most of those are unnecessary no matter the

> > complexity of the program your creating. I'm not

> > saying I think Java should be simpler, I'm just

> > saying that it doesn't need many of the little

> things

> > like the 8 I listed above. For example, why

> doesn't

> > it automatically default variables to null or 0 if

> > undefined? That way you wouldn't have to define

> every

> > single variable in your program at the top.

>

> Variables are assigned a default value if they're

> class members. If not, is it really that hard to add

> "= 0" to the end of the declaration?

Okay, I know it wouldn't be a big deal, but that's just a small example.

> > And why

> > is passing Graphics g to everything you use it in

> > necessary? Why can't they just make it where it's

> > automatically there? Or get rid of it altogether,

> I

> > don't see the point of even say "g."... Why not

> just

> > "fillRect( x, y, width, height )"?

>

> Because there can be many graphics contexts that you

> can draw on. There are images, the contents of

> components, etc. If you couldn't specify where to

> draw, it would severly limit what you could do.

Okay, I understand that, but that still doesn't mean you should have to pass g into everything you need it for. Why can't it just be global?

What about "Why does it matter if a method is static and you reference a non-static method?" and "Why doesn't java automatically import all needed classes and API's for you instead of you manually having to do it at the top?" and "Why do you need all the methods for something you implement such as MouseListener if you're not going to use them?".

GilGalvantia at 2007-7-21 22:28:23 > top of Java-index,Java Essentials,New To Java...
# 22

> 1) Why doesn't it default variables to 0 or null if you don't define them?

The rationale is that this may be sweeping oversights under the rug -- you

forgot to set foo to 17 as you intended, and silently setting it to 0 is going to

introduce bugs, not help you.

2) Why does it matter if a method is static and you reference a non-static method?

I won't explain that here, but basically you are goofing up and not

understanding the basics or method invocation and object instantiation.

3) Why do you have to pass the graphics class into every method you want to use it in? Why can't it just be global?

In general, introducing global objects should be done very sparingly.

In the case of the graphics objects used for painting, they are disposed

at the end of a call to paint, so you should not maintain a reference to them.

4) Why doesn't java automatically import all needed classes and API's for you instead of you manually having to do it at the top?

The API is too big for that. Many IDEs simplify this, though.

5) Why do you need double equal signs to evaluate equality instead of a single one? Java should have the ability to realize which one you're wanting without problem like in basic.

BASIC gets around this by treating assignment as a statement, not an expression. In Java (and various languages in the C family) you can write:

if ((ch = in.read()) != -1)

which has an assignment inside a larger expression. This is often

useful and I miss it when I write in other languages.

It's not hard to learn to write ==

6) Why do you need all the methods for something you implement such as MouseListener if you're not going to use them?

extends MouseAdapter instead of directly implementing MouseListener.

Problem solved!

7) Why does all the input have to be defined to it's respective method? Why can't I say "if( mousePressed == true )" in the main method?

I don't know what you mean. Are you asking why we need to program in

an event-driven manner?

8) Why do you need a specific method to paint?

One needs specific methods to do specific things. Less magic.

DrLaszloJamfa at 2007-7-21 22:28:24 > top of Java-index,Java Essentials,New To Java...
# 23

> What about "Why does it matter if a method is static

> and you reference a non-static method?"

Read about class variables, it explains what static means: http://java.sun.com/docs/books/tutorial/java/javaOO/classvars.html

> and "Why

> doesn't java automatically import all needed classes

> and API's for you instead of you manually having to

> do it at the top?"

What if there were two classes call Foo, one in the standard java library, and one that you wrote yourself. What if you referred to it in your code simply as Foo, not by the fully qualified package name? How would the compiler know which one you wanted? You don't have to import anything anyway, you can use the full name for everything in your code. i.e. java.util.List aList = new java.util.ArrayList();

> and "Why do you need all the

> methods for something you implement such as

> MouseListener if you're not going to use them?".

Because the MouseListener interface defines all five of those methods. That interface could be split into 5 different ones each with one method, but then you'd have to implement 5 different interfaces to get all the functionality. An interface defines a contract that your class agrees to when it implements it. Any other code can call any of the methods in that interface, so they have to be implemented, even if it doesn't actually do anything.

hunter9000a at 2007-7-21 22:28:24 > top of Java-index,Java Essentials,New To Java...
# 24

> 7) Why does all the input have to be defined to it's

> respective method? Why can't I say "if( mousePressed

> == true )" in the main method?

>

> I don't know what you mean. Are you asking why we

> need to program in

> an event-driven manner?

Kind of. In BASIC, say to move a box across the screen using the arrowkeys, you would do something like:

ink rgb( 200, 0, 0 ), 0 //set box color to red

y1 = 50 //initial y value

DO //start main loop

cls //clear the screen every loop

box x1, y1, x1 + 50, y1 + 50 //draw box

IF mouseclick() = 1 //if you click the left mouse button

x1 = x1 + 1 //move x value over one every loop

ENDIF //end if statement

LOOP //end main loop

So you don't have to have an entire method devoted to doing something if the mouse is clicked. This way you also don't have a hundred boolean statements saying things like:

"if( hasSelectedPlayer == false )" and "hasStartedGame == true", so you would check for the mouseclick in certain locations at certain times.

> 8) Why do you need a specific method to paint?

>

> One needs specific methods to do specific things.

> Less magic.

I don't think you do though. For example, see the code above. There is not "paint method" it's all implemented into one part, where you don't have to have specific method recalled every time something occurs that would change the screen.

GilGalvantia at 2007-7-21 22:28:24 > top of Java-index,Java Essentials,New To Java...
# 25

> I don't think you do though. For example, see the code above. There is not

> "paint method" it's all implemented into one part, where you don't have to have

> specific method recalled every time something occurs that would change the

> screen.

For painting to occur, there is a paint method somewhere. Perhaps you didn't

write it or you didn't invoke it directly, but it is there.

DrLaszloJamfa at 2007-7-21 22:28:24 > top of Java-index,Java Essentials,New To Java...
# 26

By the way, I understand that Java isn't BASIC, I just keep comparing them to point out simple things that could be a lot easier and accomplish the same thing, and it's the only other language I know to compare it to. The only reason I'm using Java right now is because BASIC can't be embedded into webpages and Java is faster.

GilGalvantia at 2007-7-21 22:28:24 > top of Java-index,Java Essentials,New To Java...
# 27
>For painting to occur, there is a paint method somewhere. Perhaps you didn't>write it or you didn't invoke it directly, but it is there.But that's the point, why should I need to invoke it in the first place? Why can't Java do it automatically?
GilGalvantia at 2007-7-21 22:28:24 > top of Java-index,Java Essentials,New To Java...
# 28

> >For painting to occur, there is a paint method

> somewhere. Perhaps you didn't

> >write it or you didn't invoke it directly, but it is

> there.

>

> But that's the point, why should I need to invoke it

> in the first place? Why can't Java do it

> automatically?

I don't know what you are referring to here. One seldom invokes

Component's paint method directly.

DrLaszloJamfa at 2007-7-21 22:28:24 > top of Java-index,Java Essentials,New To Java...
# 29

> > >For painting to occur, there is a paint method

> > somewhere. Perhaps you didn't

> > >write it or you didn't invoke it directly, but it

> is

> > there.

> >

> > But that's the point, why should I need to invoke

> it

> > in the first place? Why can't Java do it

> > automatically?

>

> I don't know what you are referring to here. One

> seldom invokes

> Component's paint method directly.

I'm referring to having to call "repaint()" everytime something on the screen changes.

GilGalvantia at 2007-7-21 22:28:24 > top of Java-index,Java Essentials,New To Java...
# 30

> I'm referring to having to call "repaint()" everytime

> something on the screen changes.

How would the vm know when it needs to repaint? It could just constantly repaint, but that would burn up cpu time unneccesarily if it only changed once every 10 seconds. All calling repaint() does is tell the vm that you want it redraw when you change something.

hunter9000a at 2007-7-21 22:28:29 > top of Java-index,Java Essentials,New To Java...
# 31
Okay, so how would I handle mouse input? What if I at the beginning the player had to select the player, then afterwards, the mouse wouldn't read that. Would the only way to do this is say something like "if( hasStarted == false )" in the mousePressed method?
GilGalvantia at 2007-7-21 22:28:29 > top of Java-index,Java Essentials,New To Java...
# 32
Usually you are doing something out of the ordinary if you needto call repaint. I've written plenty of Swing UIs where I didn't call repaint even once.
DrLaszloJamfa at 2007-7-21 22:28:29 > top of Java-index,Java Essentials,New To Java...
# 33

> Okay, so how would I handle mouse input? What if I at

> the beginning the player had to select the player,

> then afterwards, the mouse wouldn't read that. Would

> the only way to do this is say something like "if(

> hasStarted == false )" in the mousePressed method?

Normally you have separate components' events handled by different code. So the button that selects the player, or whatever, only get's run when the select player button is clicked. After you're done selecting players, don't show that button anymore, and you don't have to worry about that code running anymore.

hunter9000a at 2007-7-21 22:28:29 > top of Java-index,Java Essentials,New To Java...
# 34

> Okay, so how would I handle mouse input? What if I at

> the beginning the player had to select the player,

> then afterwards, the mouse wouldn't read that. Would

> the only way to do this is say something like "if(

> hasStarted == false )" in the mousePressed method?

If the behaviour of a mouse listener needs to change, among your options are:

1. defining a property like started, as you write.

2. Have different mouse listeners: say InitialMouseListener and PlayngMouseListener,

and switching them as appropriate.

This is just basic object-oriented design and programming. You would do exactly

the same in VB.NET.

DrLaszloJamfa at 2007-7-21 22:28:29 > top of Java-index,Java Essentials,New To Java...
# 35
Okay, so back to the original question. All I want is to figure out how to get the simplest possible applet running from a website. What do I do? Where do I start? Do I need to upload something? How can I make it so others can play it without downloading it?
GilGalvantia at 2007-7-21 22:28:29 > top of Java-index,Java Essentials,New To Java...
# 36
You can start by writing your application as an applet.Users won't be able to do anything with it unless they download it.
bryanoa at 2007-7-21 22:28:29 > top of Java-index,Java Essentials,New To Java...
# 37
Then how are people able to run programs from the internet without downloading? And it is an applet.
GilGalvantia at 2007-7-21 22:28:29 > top of Java-index,Java Essentials,New To Java...
# 38
Impossible. The applet code has to be downloaded and executed locally on the persons machine. This is what an applet is and how it works.
bryanoa at 2007-7-21 22:28:29 > top of Java-index,Java Essentials,New To Java...
# 39
Do you have the html written to load the applet on the page?
hunter9000a at 2007-7-21 22:28:29 > top of Java-index,Java Essentials,New To Java...
# 40

> Impossible. The applet code has to be downloaded and

> executed locally on the persons machine. This is

> what an applet is and how it works.

Then how are any of the games on pages like this done? http://www.addictinggames.com/

And, no, I don't know what the html file needs.

GilGalvantia at 2007-7-21 22:28:29 > top of Java-index,Java Essentials,New To Java...
# 41
Those are not Java applets, those are Shockwave Flash games. Completly different technology.
bryanoa at 2007-7-21 22:28:29 > top of Java-index,Java Essentials,New To Java...
# 42

> > Impossible. The applet code has to be downloaded

> and

> > executed locally on the persons machine. This is

> > what an applet is and how it works.

>

> Then how are any of the games on pages like this

> done? http://www.addictinggames.com/

>

> And, no, I don't know what the html file needs.

Ah, well then you're missing a big chunk of the puzzle. When someone browses to your webpage, there's a bit of html that handles loading the applet and running it on the page. I'm not up to date on how to use it, but here are some resources:

http://java.sun.com/docs/books/tutorial/deployment/applet/html.html

http://java.sun.com/docs/books/tutorial/deployment/applet/applettag.html

hunter9000a at 2007-7-21 22:28:29 > top of Java-index,Java Essentials,New To Java...
# 43
Okay, well what about these on this page: http://www.dgp.toronto.edu/~mjmcguff/learn/java/07-backbuffer/how are they done?Okay, thanks for those links, I'll check them out.
GilGalvantia at 2007-7-21 22:28:29 > top of Java-index,Java Essentials,New To Java...
# 44

That is an applet, if you peek into the HTML source code, you'll see this tag:

<applet width=300 height=300 code="Backbuffer1.class">

( <font color="red">You need to enable Java to see this applet.</font> )

</applet>

That tells the browser to download Backbuffer1.class and execute it as an applet in the space provided.

The code is downloaded in order to be executed on your machine.

bryanoa at 2007-7-21 22:28:29 > top of Java-index,Java Essentials,New To Java...
# 45

> Okay, well what about these on this page:

> http://www.dgp.toronto.edu/~mjmcguff/learn/java/07-bac

> kbuffer/

>

> how are they done?

>

> Okay, thanks for those links, I'll check them out.

Look at the source of that page, you'll see the <applet> tag where they're loading it.

Wasn't there a tool that came with the jdk that would generate the html for your applet automatically? I swear I remember using something like that ages ago. I can't remember what it was called.

hunter9000a at 2007-7-21 22:28:34 > top of Java-index,Java Essentials,New To Java...
# 46
That software is called HtmlConverter, it comes with the JDK, but it converts the standard applet tag to one that would execute the code in Sun's Java Plug-in. That isn't needed with todays browsers and VMs though.
bryanoa at 2007-7-21 22:28:34 > top of Java-index,Java Essentials,New To Java...
# 47

> That is an applet, if you peek into the HTML source

> code, you'll see this tag:

>

> <applet width=300 height=300

> code="Backbuffer1.class">

> ( <font color="red">You need to enable Java to see

> this applet.</font> )

>

> </applet>

>

> That tells the browser to download Backbuffer1.class

> and execute it as an applet in the space provided.

>

> The code is downloaded in order to be executed on

> your machine.

Oh, well, I don't mind that kind of downloading, I thought you meant an actual downloading of an exe. So if I use that HTML then it should automatically download the class to use on the internet?

GilGalvantia at 2007-7-21 22:28:34 > top of Java-index,Java Essentials,New To Java...
# 48

> Oh, well, I don't mind that kind of downloading, I

> thought you meant an actual downloading of an exe. So

> if I use that HTML then it should automatically

> download the class to use on the internet?

Yep. Just like the browser automatically downloads images when it hits an <img> tag.

hunter9000a at 2007-7-21 22:28:34 > top of Java-index,Java Essentials,New To Java...
# 49
You will have to place your class file in the same directory as the HTML file, and then make sure if the code attribute of the applet tag that you have named your class correctly.That should do it.
bryanoa at 2007-7-21 22:28:34 > top of Java-index,Java Essentials,New To Java...
# 50
Okay, thanks. So now what would I do to actually imbed it into the webpage? Would I need to upload the class anywhere? Then would I just put that html code into the webpage?
GilGalvantia at 2007-7-21 22:28:34 > top of Java-index,Java Essentials,New To Java...
# 51
Yes, the web server serving out the HTML page would need the HTML page itself ( with the applet tag ) and the Java class file.The browser would then see the applet tag and request the class file from the server and execute it as an applet.
bryanoa at 2007-7-21 22:28:34 > top of Java-index,Java Essentials,New To Java...
# 52
Ahh okay. And how would I upload the class to the server? Do you know of any free sites I could try this out on?
GilGalvantia at 2007-7-21 22:28:34 > top of Java-index,Java Essentials,New To Java...
# 53
You could do this one your machine, just install a little web browser like apache or Tomcat and you can test it directly from your machine.
bryanoa at 2007-7-21 22:28:34 > top of Java-index,Java Essentials,New To Java...
# 54
Thanks, I'll look into those. Thanks for the help.
GilGalvantia at 2007-7-21 22:28:34 > top of Java-index,Java Essentials,New To Java...
# 55
I meant to say install a little web server, not a web browser.
bryanoa at 2007-7-21 22:28:34 > top of Java-index,Java Essentials,New To Java...
# 56
Okay, I've installed Apache Tomcat and looked through some FAQ and readme, and I'm very confused. Have you ever used it? I know a lot of programming (BASIC), but have no clue how things like this work. Where do I even start to set one up?
GilGalvantia at 2007-7-21 22:28:34 > top of Java-index,Java Essentials,New To Java...
# 57

For example, it seems I need it in a .war file, or do I need to compress it to that? is it optional? And whats a .jsp file? It looks like a cross between a .java and .html file. It annoys me that they assume that you know all this and it's hard to find a good tutorial that doesn't assume you already know half the things it discusses and everything else about computers.

GilGalvantia at 2007-7-21 22:28:34 > top of Java-index,Java Essentials,New To Java...
# 58

> For example, it seems I need it in a .war file, or do

> I need to compress it to that? is it optional? And

> whats a .jsp file? It looks like a cross between a

> .java and .html file. It annoys me that they assume

> that you know all this and it's hard to find a good

> tutorial that doesn't assume you already know half

> the things it discusses and everything else about

> computers.

Running your own webserver is way overkill for this. Just go to a free website like geocities, angelfire, etc. and make a site. I had an angelfire site way back in the day that I had an applet on, it was super easy. the war and jsp stuff is getting in to servlets and web apps, which you don't need to touch to run a simple applet.

hunter9000a at 2007-7-21 22:28:34 > top of Java-index,Java Essentials,New To Java...
# 59

> > For example, it seems I need it in a .war file, or

> do

> > I need to compress it to that? is it optional? And

> > whats a .jsp file? It looks like a cross between a

> > .java and .html file. It annoys me that they

> assume

> > that you know all this and it's hard to find a

> good

> > tutorial that doesn't assume you already know half

> > the things it discusses and everything else about

> > computers.

>

> Running your own webserver is way overkill for this.

> Just go to a free website like geocities, angelfire,

> etc. and make a site. I had an angelfire site way

> back in the day that I had an applet on, it was super

> easy. the war and jsp stuff is getting in to servlets

> and web apps, which you don't need to touch to run a

> simple applet.

Okay, so what would I do once I get a site? Where do I upload the files?

GilGalvantia at 2007-7-21 22:28:34 > top of Java-index,Java Essentials,New To Java...
# 60
Any decent web host should give you the instructions for this themselves - most likely through a "webshell" type interface if you're completely new to it.
DavidKNa at 2007-7-21 22:28:39 > top of Java-index,Java Essentials,New To Java...
# 61

> Any decent web host should give you the instructions

> for this themselves - most likely through a

> "webshell" type interface if you're completely new to

> it.

Angelfire had this type of setup, where you'd just click a button to upload a file, and tell it what directory to put it in. Very simple, though it'll probably vary from site to site.

hunter9000a at 2007-7-21 22:28:39 > top of Java-index,Java Essentials,New To Java...
# 62
Okay, I've uploaded the class file and put the HTML on the site, but it just shows up as an empty box with an x. Any idea what's wrong? http://gilgalvanti.angelfire.com/
GilGalvantia at 2007-7-21 22:28:39 > top of Java-index,Java Essentials,New To Java...
# 63

> Okay, I've uploaded the class file and put the HTML

> on the site, but it just shows up as an empty box

> with an x. Any idea what's wrong?

> http://gilgalvanti.angelfire.com/

java.lang.UnsupportedClassVersionError: Bad version number in .class file

You've compile your applet, with I guess 1.6 and your browser plug in is 1.5 or earlier.

cotton.ma at 2007-7-21 22:28:39 > top of Java-index,Java Essentials,New To Java...
# 64
so would it be better to compile it in 1.5 or find the browser plug in for 1.6. Does a plugin for 1.6 exist? How can I compile it in 1.5
GilGalvantia at 2007-7-21 22:28:39 > top of Java-index,Java Essentials,New To Java...
# 65
> so would it be better to compile it in 1.5 or find> the browser plug in for 1.6. Does a plugin for 1.6> exist? How can I compile it in 1.5Just compile to a 1.5 (or so) target.
cotton.ma at 2007-7-21 22:28:39 > top of Java-index,Java Essentials,New To Java...
# 66
Look for the section entitled cross-compilation options and target switch. http://java.sun.com/javase/6/docs/technotes/tools/windows/javac.html#options
cotton.ma at 2007-7-21 22:28:39 > top of Java-index,Java Essentials,New To Java...
# 67

I get this when I try to do what it says:

C:\Program Files\Xinox Software\JCreatorV3LE\MyProjects>javac -target 1.5 -bootc

lasspath jdk1.5.0/lib/rt.jar/-extdirs "" Problems.java

An exception has occurred in the compiler (1.6.0_01). Please file a bug at the J

ava Developer Connection (http://java.sun.com/webapps/bugreport) after checking

the Bug Parade for duplicates. Include your program and the following diagnosti

c in your report. Thank you.

java.lang.StringIndexOutOfBoundsException: String index out of range: 0

at java.lang.String.charAt(String.java:687)

at com.sun.tools.javac.main.Main.processArgs(Main.java:180)

at com.sun.tools.javac.main.Main.compile(Main.java:309)

at com.sun.tools.javac.main.Main.compile(Main.java:279)

at com.sun.tools.javac.main.Main.compile(Main.java:270)

at com.sun.tools.javac.Main.compile(Main.java:69)

at com.sun.tools.javac.Main.main(Main.java:54)

C:\Program Files\Xinox Software\JCreatorV3LE\MyProjects>

GilGalvantia at 2007-7-21 22:28:39 > top of Java-index,Java Essentials,New To Java...
# 68
/bump anyone know what I'm doing wrong?
GilGalvantia at 2007-7-21 22:28:39 > top of Java-index,Java Essentials,New To Java...
# 69
So you're telling the 1.6 compiler to generate 1.5 bytecode? It looks like there's a compiler bug. Try using the actual 1.5 compiler. Do you have the 1.5 jdk installed?
hunter9000a at 2007-7-21 22:28:39 > top of Java-index,Java Essentials,New To Java...
# 70
Yes, I have the compiler installed, but how would I use that one instead of 1.6? I'm just compiling from the JCreator IDE.
GilGalvantia at 2007-7-21 22:28:39 > top of Java-index,Java Essentials,New To Java...
# 71
> Yes, I have the compiler installed, but how would I> use that one instead of 1.6? I'm just compiling from> the JCreator IDE.I don't know, I've never used JCreator. Check the documentation.
hunter9000a at 2007-7-21 22:28:39 > top of Java-index,Java Essentials,New To Java...
# 72
Looked through the little documentation it had, and didn't see anything. Can't I do it from the command console?
GilGalvantia at 2007-7-21 22:28:39 > top of Java-index,Java Essentials,New To Java...
# 73

> Looked through the little documentation it had, and

> didn't see anything. Can't I do it from the command

> console?

Yes you can, in fact, I'd recommend it. Here's a tutorial that shows you how to compile and run your code from the command line:

http://java.sun.com/docs/books/tutorial/getStarted/cupojava/index.html

hunter9000a at 2007-7-21 22:28:39 > top of Java-index,Java Essentials,New To Java...
# 74

> > Looked through the little documentation it had,

> and

> > didn't see anything. Can't I do it from the

> command

> > console?

>

> Yes you can, in fact, I'd recommend it. Here's a

> tutorial that shows you how to compile and run your

> code from the command line:

> http://java.sun.com/docs/books/tutorial/getStarted/cup

> ojava/index.html

Thanks, but I already know how to compile them from the command line, but I'm asking how to compile them in 1.5 instead of 1.6 from the command line. The way that I tried already is shown above.

GilGalvantia at 2007-7-21 22:28:39 > top of Java-index,Java Essentials,New To Java...
# 75

If you have 1.5 jdk installed already, you can either change your path so that it picks up the javac under the 1.5 directory, or call the correct javac version directly:

C:> C:\Program Files\Java\jdk1.5\bin\javac blah blah blah

Basically if you have multiple jdks installed, you have multiple versions of javac, and you just need to tell the system which one to run when you use javac.

hunter9000a at 2007-7-21 22:28:44 > top of Java-index,Java Essentials,New To Java...
# 76

> If you have 1.5 jdk installed already, you can either

> change your path so that it picks up the javac under

> the 1.5 directory, or call the correct javac version

> directly:

> C:> C:\Program Files\Java\jdk1.5\bin\javac blah

> blah blah

> Basically if you have multiple jdks installed, you

> have multiple versions of javac, and you just need to

> tell the system which one to run when you use javac.

Yeah but that's what I'm confused on how to do. What co I need to type to get it to compile the old version?

GilGalvantia at 2007-7-21 22:28:44 > top of Java-index,Java Essentials,New To Java...