I write an applet which includes some audio files, VRML file and some image files:
audio(folder,including .wav)
img(folder,including .gif,.jpg for the buttons in my applet)
test.wrl
MyApplet1.class,MyApplet2.class,......(myApplet1 is the main class)
at the current path I use jar tools to compress the above files:
jar cvf MyApplet.jar *.*
and I write a test.html:
<applet
code = "MyApplet1.class"
archive = "MyApplet.jar"
name = "TestApplet"
width = "640"
height = "480"
>
</applet>
so the current path is :
MyApplet.jar
test.html
I open the test.html in IE then the applet console tell me as following:
IOException reading data: java.io.FileNotFoundException: F:\myapplet\test.wrl (can not
find the file.)
java.io.FileNotFoundException: F:\myapplet\test.wrl (can not find the file.)
And I cannot load the image files too.But I am confused that when I move the VRML file
and the image files out of the .jar ,just like as following:
MyApplet.jar
img(folder,including .gif,.jpg for the buttons in my applet)
test.wrl
test.html
so the applet can run!--the audio files can be included in the .jar!
I am appreciated to get the reply from anybody.
some codes as following:
***************************************************************************
load audio:
..
AudioClip crowdcheer = getAudioClip(codeBase, "audio/audio1.wav");
..
***************************************************************************
load VRML:
..
String file = "/test.wrl";
codeBase = getCodeBase();
URL filePath = null;
try {
filePath = new URL(codeBase.toString() + file);
} catch (MalformedURLException malformedurlexception1) {
System.err.println(malformedurlexception1);
System.exit(1);
}
BranchGroup sceneGroup = loadVRML(filePath);
..
BranchGroup loadVRML(URL filename) {
VrmlLoader l = new VrmlLoader();
try {
scene = l.load(filename);
} catch (FileNotFoundException e) {
System.err.print(e);
System.exit(1);
} catch (ParsingErrorException e) {
System.err.print(e);
System.exit(1);
} catch (IncorrectFormatException e) {
System.err.print(e);
System.exit(1);
}
BranchGroup bg = scene.getSceneGroup();
return bg;
}
***************************************************************************
load image:
..
try{
URL url1 = ddd.codeBase;
iconpath1 = new URL(url1.toString() + "/images/ButtonHome.gif");
iconpath2 = new URL(url1.toString() + "/images/top10.gif");
}
catch(MalformedURLException malformedurlexception){
System.err.println(malformedurlexception);
System.exit(1);
}
icon1=new ImageIcon(iconpath1);
icon2=new ImageIcon(iconpath2);
..
cs
2004-08-06
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".