Computing desk | ||
---|---|---|
< July 19 | << Jun | July | Aug >> | July 21 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
I am developing a java applet for independent research. The file is intended to read the directory the applet is running from, using the code:
String currentDir = new File(".").getAbsolutePath();
.... after that it flushes an image buffer to png image format. However, i forgot that, unlike java applications, java applets are highly restricted. As expected, the code above causes the applet to throw a security exception, because my applet isn't signed. I was reading this page:
http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html
... there seem to be many steps just to allow access to the local file system. Is there any easier way to just tell the browser that the applet it is loading is MINE and that i accept its use of my files? I would rather not go find out how to make a public key, a certificate, and a security policy. Thanks in advance!
172.163.3.207 (talk) 03:42, 20 July 2012 (UTC)
JApplet
to a JFrame
with a static main(String[])
method that properly instantiates your JFrame
and invokes your init
and start
methods. Of course if you're only running the applet locally, then you probably have some reason why you need it to stay in applet form. Could you upload the file to a LAN server and have the applet fetch it? BigNate37(T) 04:46, 20 July 2012 (UTC)
So.... Container pane = getContentPane(); becomes a JFrame instead? Would the class still extend JApplet, or something else? Also, once i figure that all out, how do i run the thing? Your suggestion seems the best way to go. I don't need it to be an applet, so long as i can still display and interact with the graphics in the same way (mouse, button listeners still work i hope) :)
172.162.254.31 (talk) 12:41, 20 July 2012 (UTC)
public static void main(String[] args) {
JFrame f = new JFrame("Applet");
f.setSize(600, 450);
JApplet app = new swingapplet(); // CHANGE THIS
f.getContentPane().add(app);
app.init();
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent w) {
System.exit(0);
}});
f.setVisible(true);
app.start();
}
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
The JDK comes with a program that allows you to run applets (as if they were applications) already - it's called appletviewer. Assuming you already have an html file index.html with the applet tag in, you just say
appletviewer index.html
And that works for lots of simple applets. But if you try that with your code, you'll still get a security exception, because the appletviewer installs its own security manager, which checks signatures and limits permissions, just as the equivalent code in a web browser does. What you can do is create your own java security policy file which allows you to grant exceptions to this security sand box just for this invocation (so it's a safer and cleaner thing to do, rather than messing around with the equivalent for your browser, and then forget to undo that, leaving your browser very vulnerable). Here's a minimal security policy file (call it my.policy) which grants total access (so it's the same as a java application gets)
grant { permission java.security.AllPermission; };
Now, with that in place, and your index.html and .class files in the same directory, you can invoke appletviewer and have it use that special policy file:
appletviewer -J-Djava.security.policy=my.policy index.html
Which should allow total access. Naturally you have to trust the code (which is fine if you wrote it, and you trust yourself), so it's obviously not a wise thing to do in general with code you didn't write and whose source you don't have good reason to trust. -- Finlay McWalterჷTalk 13:48, 20 July 2012 (UTC)
I used the wrapper option. It works wonderfully, thank you all for the input! 172.162.132.72 (talk) 01:08, 21 July 2012 (UTC)
When I type things like \begin{equation}, how do I make it automatically give \end{equation}? Money is tight (talk) 05:38, 20 July 2012 (UTC)
Does anybody know why colours displayed on a TFT monitor are darker at the top of the screen than at the bottom? Suppose I have a small window containing a simple graphic (eg a blue arrow). If the window is at the top of the screen, the blue is much darker than if the window is at the bottom of the screen. If happens in both Linux and Windows XP, so clearly it is something the monitor is doing. It does it in both daylight and artificial light too. It makes getting the colours right when editing graphics very tricky. Thanks! --TrogWoolley (talk) 09:58, 20 July 2012 (UTC)
Hi, I live in Australia, and I'd like to buy some PS3 games from overseas, cos you know, gaming outlets love to overcharge us Aussies. Anyway, I'm wondering what the differences are between the Australian and UK PAL versions, as well as PAL versions from other countries, and whether they'd cause any significant changes in gameplay. I've been given to understand that NTSC games are also compatiable with my PAL PS3 provided that I've got HD connection with my TV (which I do) -- can somebody confirm this? Also, can somebody point me to an official article that explains the differences between: the PAL regions; and between PAL and NTSC versions? It'll be great if people can respond to my queries. Thanks --Sp33dyphil ©hatontributions 10:35, 20 July 2012 (UTC)
Why (I think) only Wikipedia's addresses can have a space instead of a underscore? Even if it gets converted, why other web-sites don't perform this trick? Persominus (talk) 13:42, 20 July 2012 (UTC)
You're referring to simple URI remapping, Apache HTTP Server would do it like so, for example. A lot of websites using Content Management Systems that weren't designed by total goobers (not as many as you might think) promote such remapping. A lot of websites have no content management system or back end to speak of, and operate much more simply. ¦ Reisio (talk) 20:53, 20 July 2012 (UTC)
To really understand this sort of issue is confusing, because there are a lot of different things going on.
So what actually happens if you construct a URL for a Wikipedia article by hand, containing a space, is that your browser converts it to %20, and Wikipedia's web server translates it back to a space, and then the higher-level Wikipedia software converts the space into an underscore when looking up the article name in the database, but displays it to you as a space. Over the river and through the woods (and twice around the barn), to Grandmother's house we go... —Steve Summit (talk) 15:00, 22 July 2012 (UTC)
what is the domain name for wikiasari — Preceding unsigned comment added by 90.194.140.253 (talk) 15:35, 20 July 2012 (UTC)
I know there is such a thing a "prt sc" to print whatever there is on the screen and save as a JPG. Is there such a thing as a video "print screen" that will capture the video on the screen (e.g. mouse moving around the screen, clicks and different screens produced; YouTube video presentations on the screen) and save as a MPEG? I have a newer HP laptop with Windows 7. Is there something in Windows Live Movie Maker that will capture video on the screen?--Doug Coldwell talk 18:24, 20 July 2012 (UTC)