Jump to content

Wikipedia:Reference desk/Archives/Computing/2012 July 21

From Wikipedia, the free encyclopedia
Computing desk
< July 20 << Jun | July | Aug >> July 22 >
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.


July 21

[edit]

Double buffering in Java fails?

[edit]

I am trying to reduce flicker in a java applet, by using a double buffering method mentioned here.

I have a slightly different set up, of course, so i did the following:

In the main method i have class members

  • private Image buffer;
  • private Graphics bufferG;


at the bottom of the init() method i do these

  • buffer = createImage(500, 500);
  • bufferG = buffer.getGraphics();

on the last line here where i say bufferG = buffer.getGraphics, i get a null pointer exception, why? The example on that website clearly has no issues like this! 172.162.132.72 (talk) 05:58, 21 July 2012 (UTC)[reply]

Ah, you've found a defect in my wrapper, I'm sorry about that. Move the call to app.init() down to after f.setVisible(true).
If you want an explanation, here it is: although I can't immediately find a formal definition, it seems (at least appletviewer does it) that init() is called on a realised widget (that is, there's a real corresponding window in the host graphics system, which isn't the case until a control is shown or attached to a shown container). The documentation for createImage() says "The return value may be null if the component is not displayable", which it won't be until its owning java.awt.Window is setVisible(true). -- Finlay McWalterTalk 11:17, 21 July 2012 (UTC)[reply]

I may have already found a solution to this. I have not modified your wrapper, rather i moved the above definitions to the update() function of the applet. The basic definition does not throw null pointer now, so i am working on migrating my graphics back to the buffer and writing code to refresh the original graphics object. I'll let you know how i come along.

PS: I agree with you. I was made aware of the return value being null and we did concede that the call was being made too early. :)

172.129.34.113 (talk) 12:18, 21 July 2012 (UTC)[reply]

It's a bit wasteful to call it in update(). update is called every time the applet needs to be redraw, which can be many times per second. createImage() is a fairly heavyweight operation - not something you want to do so often if you can avoid it. -- Finlay McWalterTalk 12:44, 21 July 2012 (UTC)[reply]

It seems that this may be something that requires code sharing. I tried the fix my friend suggested and it "worked" but still flickered. I prefer, if possible, to share my source privately. Is there any way i can grab some sort of contact detail from you, Finlay?

172.129.34.113 (talk) 12:56, 21 July 2012 (UTC)[reply]

wiping personal information from a phone

[edit]

I want to recycle my old smartphone, but I am concerned someone could recover personal information from it. Please tell me if these steps are adequate:

  • Run the feature called "restore phone to factory conditions"
  • Pull out the SD card

ike9898 (talk) 12:03, 21 July 2012 (UTC)[reply]

What sort of phone is it? The instructions will probably vary from model to model, OS to OS. Generally, information is held in three places: the SIM card, the internal memory, and the removable memory (SD card); wiping these in the way you describe would normally be sufficient. There are various guides available, here is a selection for iPhone, Android and Blackberry. - Cucumber Mike (talk) 12:12, 21 July 2012 (UTC)[reply]
Like cucumber says it's critical to know what kind of phone it is. But as for the iPhone, there is a built in wipe feature that should overwrite most of the volatile memory (you'll probably still want to remove the SIM card). I don't know if there's been any in depth discussion of how good that wipe is, but it should suffice for most people's purposes. Shadowjams (talk) 19:09, 21 July 2012 (UTC)[reply]

Comments in Google Blogger

[edit]

I'm setting up a blog, and struggling with the really nice intuitive interface, because I'm no good at these things. I thought I set it up so anyone could comment, even if not logged in. But when I log out and then try to comment on a post, it seems to require a login of some kind, whether Google or Open ID or a number of others. But no guest option. Can you give me a lead? I may be back for more help soon if that's all right. Itsmejudith (talk) 18:42, 21 July 2012 (UTC)[reply]


Whether anonymous comments are allowed seems to be a per-blog setting. This video discusses how you, as the blog owner, can change that setting. -- Finlay McWalterTalk 19:01, 21 July 2012 (UTC)[reply]
I don't know how to get to the page where the video starts. Perhaps it has changed recently? Itsmejudith (talk) 20:30, 21 July 2012 (UTC)[reply]
It had. I got in via the old interface. It is definitely set that Anyone, including anonymous users can post. But they can't. Do you know of a forum where I could get help from users? Itsmejudith (talk) 08:10, 22 July 2012 (UTC)[reply]
Try this: https://productforums.google.com/forum/#!forum/blogger --My Ubuntu (talk) 04:18, 23 July 2012 (UTC)::::[reply]
the same question as mine, with no helpful responses and they wouldn't let me post to the forum ;-( Itsmejudith (talk) 22:30, 23 July 2012 (UTC)[reply]
sorry, didn't notice that --My Ubuntu (talk) 22:51, 27 July 2012 (UTC)[reply]

Levels in computer languages

[edit]

Does the JVM work by input of Java code and output of machine code? Or is there any additional layer there? Do other interpreted languages (Perl, Python, javascript) also work like that? Why would you need an additional layer of abstraction? OsmanRF34 (talk) 19:46, 21 July 2012 (UTC)[reply]

No, the JVM is a virtual machine. It works by input of machine code and output of actions. The distinctive thing about Java is that instead of being compiled into machine code that is specific to the type of computer a program runs on, it is always compiled into machine code for the same machine, the Java Virtual Machine. If you don't understand what machine code is and what it means to "compile" a program, this explanation may look like gobbledegook, but those are not things that can be explained in a short answer. Looie496 (talk) 00:20, 22 July 2012 (UTC)[reply]
Does it work by "by input of machine code and output of actions"? It takes a Java bytecode file as input and perform some actions. Is that machine code? OsmanRF34 (talk) 13:46, 22 July 2012 (UTC)[reply]
Yes. Java bytecode is the machine code for the Java Virtual Machine. Looie496 (talk) 16:11, 22 July 2012 (UTC)[reply]
As Looie pointed out the advantage of having the additional abstraction is portability. However, there are situations where the python/java virtual machine will perform Just-in-time compilation on to convert the bytecode to manative machine code. This is reserved for highly called functions/loops where the performance gains of native code outweigh the cost of compilation. The android DVM and certain python modules support this.Staticd (talk) 03:59, 22 July 2012 (UTC)[reply]
Machine code is the instructions that are present as voltages on the pins of the microprocessor at the instant that the processor reads in an instruction. Virtual machine instructions are data that are read while a program that emulates a virtual machine is executing and are handled by the program in a manner analogous to the way a hardware processor handles machine code. So virtual machine instructions are treated as data, not instructions, by the actual hardware. Jc3s5h (talk) 16:04, 22 July 2012 (UTC)[reply]
So, the java bytecode is an 'as if' machine code? A kind of virtual machine code for the virtual machine? But no real machine code, unless in the cases pointed out by Staticd. OsmanRF34 (talk) 18:01, 22 July 2012 (UTC)[reply]
I don't think what Jc3s5h said is quite correct. A machine code is a code that attaches a number to each possible machine language instruction -- it doesn't intrinsically have anything to do with voltages and pins. Java bytecode is the machine code for the virtual machine. There have actually, by the way, been several attempts to build a physical machine whose machine language matches the Java Virtual Machine instruction set -- they are known as Java processors, but none has been commercially successful, as far as I know. Looie496 (talk) 18:17, 22 July 2012 (UTC)[reply]
Java is not always compiled to the JVM. gcj compiles directly to machine code. Android apps are programmed in Java but compiled to Dalvik code, which is different from JVM bytecode.
The JVM is not a necessary part of Java. Java was in fact defined as both a programming language and a bytecode VM for that language, but there are tons of Java-like languages that are defined without a VM. You don't even need the VM for portability in the usual meaning of that term. Java programs are relatively portable because Java specifies a lot of things that are left unspecified in other languages, such as the exact size of integers, and because it has cross-platform libraries for practically everything. These benefits still exist if you distribute Java as source code or if you compile it to machine code for every platform you care about. Javascript (an unrelated language) is distributed as source code. What the JVM buys you over source code is a certain amount of obfuscation (important to people who don't want to distribute their source code) and a bit of time savings since you don't have to parse the source code when you run it. -- BenRG (talk) 19:53, 22 July 2012 (UTC)[reply]
The OP asked "Does the JVM work by the input of Java code and the output of machine code?"; the answer depends on what you mean by "Java code". There is Java source code, which (practically) no JVM executes, and there is Java byte code, which is a set of instructions that are executed by the JVM. You could say that the JVM takes java byte code and executes (not output) the machine code on the CPU where the JVM is running. So the answer to the question you meant, if my assumptions and interpretations are correct, could be a qualified "yes".
"Machine code" usually refers to the binary code executed directly by a CPU (whether you think of it as a collection of numbers or a collection of voltages); it can have other meanings, but usually is used in a context where speed is being referenced. CPUs typically execute their code faster than any interpreter on a similar machine, and it is only by delegating the CPU-intensive parts of programs to machine code that allow Java programs to run as fast as their machine-code equivalents. This intends no denigration of the language, only pointing out the reality that interpretation consumes CPU cycles by itself and is therefore inherently slower than equivalent machine code. (It USED to be that you could count on a Java program to run slower than a "natively compiled" program -- this is no longer true at all; I think the differences these days have more to do with the team of programmers and their design, not the language).
As to layers of abstraction: Java was originally intended to be used on different devices (kitchen appliances, for example), and so the layer of abstraction was useful for allowing different CPUS to run the same program through a JVM. It melded nicely into the then-new World Wide Web, with its different CPUs and browsers, and the Web is where it gained its popularity. rc (talk) 02:40, 26 July 2012 (UTC)[reply]

Can I show "My Documents" as "Documents" in Windows 7 GUI?

[edit]

In Windows 7 (Enterprise), in the GUI windows explorer one of the folders always shows as "My Documents". In the command shell, that folder (DIR), shows as "Documents". Is there any way to change the GUI so that it shows that folder as "Documents" and not "My Documents"? RudolfRed (talk) 22:27, 21 July 2012 (UTC)[reply]

You should be able to simply rename it from Explorer. Eg, right-click "My Documents" and rename it to "Documents" (or whatever...) Mitch Ames (talk) 03:58, 22 July 2012 (UTC)[reply]
I didn't even try that before asking. I simply assumed it was special in some way and that normal renaming wouldn't work, but I just did it and it seems to be okay. Thanks. RudolfRed (talk) 01:07, 23 July 2012 (UTC)[reply]
It is "special" - it contains a hidden "desktop.ini" files (as do other "special" folders) which tell Explorer how to display the folder. That file gets updated when you manipulate it with Explorer, and many of the "normal" Explorer actions still work as expected. Eg you can drag/drop the folder somewhere other than under "c:\users\yourname", and Windows will still find it from the "Documents" item on the Start menu. (Be sure to do a backup before you try this, though, just in case.) Mitch Ames (talk) 12:41, 24 July 2012 (UTC)[reply]

How to show just ONE taskbar button per InternetExplorer9 window in Windows7 (Instead of one per tab)

[edit]
Resolved

I can not find the option anywhere ;-(
How can I limit the taskbar to show just one button for each open InternetExplorer9 window? (Instead of one for each TAB from IE as it is currently showing)
--89.9.192.43 (talk) 22:50, 21 July 2012 (UTC)[reply]

I'm afraid i don't know how to do that in IE, but i know that FireFox has the behavior you want by default. :)
172.163.3.37 (talk) 22:57, 21 July 2012 (UTC)[reply]

[1] 92.233.64.26 (talk) 23:19, 21 July 2012 (UTC)[reply]

Problem resolved. Thank you both! :-)
-- (OP) 89.9.211.153 (talk) 20:46, 26 July 2012 (UTC)[reply]