• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Java Help!

alfa147x

Lifer
I am running a wordpress blog, I would like to put some of my Java apps on the site, but they all end with .class

Thanks

or here is an example before compile:

import java.util.Random;
import java.lang.String;
import java.lang.IndexOutOfBoundsException;

public class NameApp


{
public static void main(String[] args)
{
//Show name

System.out.println("asdff");

//make name var.

String myName = "asdff";

//Gen. Number

Random myRandom = new Random();
int answer;

//Specify number

answer = myRandom.nextInt(5);

//Show Number

System.out.println(answer);

//Show Ran letter

System.out.println(myName.charAt(answer));


}
}
 
Last edited:
A class file is what you need in order for your applet to be usable. The .java file is just source code and the .class file is source code that has already been compiled. It's been a while since I've written anything in Java, but here are 2 things I remember that you certainly need in order to turn this into an applet:

1) Import the applet library (java.applet.* should do)
2) After "public class nameApp" you should put "extends Applet"

I don't remember if you need anything else in the Java code itself. Obviously, you also need to write the appropriate HTML code in your page to display the applet. The last time I did something like this, I used the applet tag in my page. However, I believe that tag has since been deprecated and you need use something like the object tag. If you need more help with the HTML, I could probably put the line of HTML you would need.

-Tom
 
Op, what do you mean by "put some of my Java apps on the site"? If you want to have them run in the viewer's browser then yeah, you have to sublcass Applet. System.out will do you no good. You actually have to use gui widgets to display something.
 
Originally posted by: kamper
Op, what do you mean by "put some of my Java apps on the site"? If you want to have them run in the viewer's browser then yeah, you have to sublcass Applet. System.out will do you no good. You actually have to use gui widgets to display something.


Does this mean i cant turn it in to an applet with only 3 lines?
 
Originally posted by: kamper
I guess you can, but what are you going to display?

What kamper has been saying is that in an applet, System.out.println will not display anything on the screen. Instead, you'll have to use a paint method in order to put the information on the webpage.

-Tom
 
kamper is right. sorry I didn't read his code..
the output will only be in console unless you use graphic. .paint method.

 
Back
Top