ellandrd
asked on
create Applet in netbean IDE 5
how can you create an applet in netbeans.
i have created my applet.java and .class files and cant run them using netbeans - right-click > compile, then right-click > Run File, but if i try running it in a webpage it dont show up!
im using the latest build of netbeans IDE 5.
I also get this error when trying to run the applet in netbeans. like it runs fine, but i get this error.
Warning: Can't read AppletViewer properties file: \\mail01abzpi\homes$\sdela ney\my documents\.hotjava\propert ies Using defaults.
in my html page i get this in the status bar:
exception: java.lang.NullPointerExcep tion
any ideas?
here is my applet.java
/*
* PCApplet.java
*
* Created on 03 February 2006, 10:48
*
*
*/
package u0207372.gui;
import javax.swing.JApplet;
/**
*
* @author u0207372
*/
public class PCApplet extends JApplet {
/** Creates a new instance of PCApplet */
public PCApplet() {
super();
PCStandalone pcs = new PCStandalone();
this.add( pcs );
}
}
here is my index.html:
<html>
<head>
<title>Pocket Calculator</title>
</head>
<body>
<applet code="PCApplet.class" width="210" height="230"></applet>
</body>
</html>
i have created my applet.java and .class files and cant run them using netbeans - right-click > compile, then right-click > Run File, but if i try running it in a webpage it dont show up!
im using the latest build of netbeans IDE 5.
I also get this error when trying to run the applet in netbeans. like it runs fine, but i get this error.
Warning: Can't read AppletViewer properties file: \\mail01abzpi\homes$\sdela
in my html page i get this in the status bar:
exception: java.lang.NullPointerExcep
any ideas?
here is my applet.java
/*
* PCApplet.java
*
* Created on 03 February 2006, 10:48
*
*
*/
package u0207372.gui;
import javax.swing.JApplet;
/**
*
* @author u0207372
*/
public class PCApplet extends JApplet {
/** Creates a new instance of PCApplet */
public PCApplet() {
super();
PCStandalone pcs = new PCStandalone();
this.add( pcs );
}
}
here is my index.html:
<html>
<head>
<title>Pocket Calculator</title>
</head>
<body>
<applet code="PCApplet.class" width="210" height="230"></applet>
</body>
</html>
I'd gladly look, but I'd have no way to test your code without the other class. However, it is possible a property file may have gotten corrupted.
Oops. Sorry... it's actually your settings we need to look at. The properties of your project you made to hold all of your code and the settings for classes, etc.
you should jar up all your class files from the project, and put it in the same directory as your html file.
Also, you should specify the code base:
<APPLET
CODEBASE = "./"
CODE = "yourappletclass.class"
NAME = "TestApplet"
WIDTH = 600
HEIGHT = 400
HSPACE = 0
VSPACE = 0
ALIGN = middle
>
</APPLET>
Also, you should specify the code base:
<APPLET
CODEBASE = "./"
CODE = "yourappletclass.class"
NAME = "TestApplet"
WIDTH = 600
HEIGHT = 400
HSPACE = 0
VSPACE = 0
ALIGN = middle
>
</APPLET>
See this link for running jar files from html
http://java.sun.com/docs/books/tutorial/deployment/jar/run.html
http://java.sun.com/docs/books/tutorial/deployment/jar/run.html
ASKER
let me first say i have never created a JAR or an applet before.
the above url told me how to create a jar, but DOS wont let me - kept getting error i didnt understand.
is there an easier way to create a applet? surely it isnt this hard?
the above url told me how to create a jar, but DOS wont let me - kept getting error i didnt understand.
is there an easier way to create a applet? surely it isnt this hard?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
>>Create another project, but use the default package
But them my class will not work correctly will they?
But them my class will not work correctly will they?
ASKER
ASKER
well any luck?
Alright, I just placed all of your files in the same folder and stripped out all of the package information from the source files. Works properly.
ASKER
yes that is OK, but im required to keep my package structure... so what now?
I'm going to try making a package out of this real quick and see what happens. (I still have NetBeans 4)
ASKER
im using netbeans 5...
i'm going to upgrade to 5... been putting it off anyway.
now i'm importing your work into netbeans 5. but i'm not having any of the errors that you've mentioned.
Alright, now I got it. But just curious, why is the Processor class separate from all the others?
ASKER
ok will when you have imported the project, build it an run it, then try run the applet using the html page i have in the u0207372 gui folder....
if i right click on the PCApplet.java and compile it and then run it, the applet viewer shows my PCApplet.java but i cant get the applet to show or work in a webpage...
where is the jar file created? or how does netbeans create the jar file?
if i right click on the PCApplet.java and compile it and then run it, the applet viewer shows my PCApplet.java but i cant get the applet to show or work in a webpage...
where is the jar file created? or how does netbeans create the jar file?
Build > Clean and Build Main Project
or
Right click on your project and choose Clean and Build Project
The output window tells you where the JAR file is located. However, I think partly based on the way your package set up is, it still causes some issues.
or
Right click on your project and choose Clean and Build Project
The output window tells you where the JAR file is located. However, I think partly based on the way your package set up is, it still causes some issues.
ASKER
will if you think about it? the displayPanel, Keypad and PCStandalone are all apart of the gui so they get there own folder. the processor isnt so it stays in the u0207372 folder.
another examples is if i had images - i'd have a image folder under u0207372.... see what i mean? it just puts them and gives the project some structure....
another examples is if i had images - i'd have a image folder under u0207372.... see what i mean? it just puts them and gives the project some structure....
Can I change the package that your Applet file is in? I think that's why you're having so damn many problems.
Never find... I finally got it this working right. I'll give you the code for the HTML page. I forgot about package references in the code.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
how did you create the jar file?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
so you put the index.html file inside the dist folder?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you soooo much - you dont now how much you've made my day!
Ellandrd
Ellandrd
No problem. I think I need to extract myself from this chair now. :)