wood burning stoves 2.0*
The moose likes Applets and the fly likes Codebase in applet not working after Java update 7-25 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Codebase in applet not working after Java update 7-25" Watch "Codebase in applet not working after Java update 7-25" New topic
Author

Codebase in applet not working after Java update 7-25

Paul Greenstock
Greenhorn

Joined: Sep 20, 2007
Posts: 4
After the latest update the following code no longer retrieves my gifs. I did read that the latest update has changed codebase to return null. The question is how to fix this. I am not using a jar, I just have the class and gifs and html in the same folder. The applet paints the screen and just sits, no error messages on the console. Can I hard code the codebase in my applet ??


public void getimages() {
int z = 0;
String filename = "";
String suffix=".gif";
String suits[] = { "h", "d", "s", "c" };
String cards[] = { "a", "2", "3", "4", "5", "6", "7", "8", "9", "t",
"j", "q", "k" };
gifs[z] = getImage(this.getCodeBase(), "b" + suffix);
gifs[53] = getImage(this.getCodeBase(), "j" + suffix);
for (int x = 0; x < 4; x++) {
for (int y = 0; y < 13; y++) {
z++;
filename = cards[y].concat(suits[x]).concat(suffix);
gifs[z] = getImage(this.getCodeBase(), filename);
}
}
}
Regina Thomas
Greenhorn

Joined: May 12, 2006
Posts: 16
Quickly checking the code- did you insure the gif files were located where the class file for the applete was located.. Are you using a JAR?

Q...


WiredPages | Remix
Paul Greenstock
Greenhorn

Joined: Sep 20, 2007
Posts: 4
Yes. And this worked perfectly until the latest update. And I'm not using a Jar.
Regina Thomas
Greenhorn

Joined: May 12, 2006
Posts: 16
I could never get that code to work while testing in my IDE-- I juse Borland and Netbeans... no matter the version of of the sdk... that said -- I can use getcodebase outside of the IDE environment.. I think I had a problem with getimage and getcodebase used together within the IDEs. I also have not updated my version of Java.. so thank you for the heads up.

Q...
Paul Greenstock
Greenhorn

Joined: Sep 20, 2007
Posts: 4
Regina, this code works (but I dont like hardcoding the folder name)

public void getimages() {
String path = "file:////f:/towers/";
String fullpath="";
int z = 0;
String suffix=".gif";
String suits[] = { "h", "d", "s", "c" };
String cards[] = { "a", "2", "3", "4", "5", "6", "7", "8", "9", "t",
"j", "q", "k" };
try {
fullpath = path.concat("b"+suffix);
gifs[z] = getImage(new URL(fullpath));
fullpath = path.concat("j"+suffix);
gifs[53] = getImage(new URL(fullpath));
for (int x = 0; x < 4; x++) {
for (int y = 0; y < 13; y++) {
z++;
fullpath = path.concat(cards[y]).concat(suits[x]).concat(suffix);
gifs[z] = getImage(new URL(fullpath));
}
}
} catch (Exception MalformedURLexception) {
System.out.println("MalformedURLexception");
}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Codebase in applet not working after Java update 7-25