# Trivia: Why does Java take so up so much space?



## Draco_2k (Sep 9, 2008)

Hope this is concise enough.

Yeah, that Java plugin for IE/Firefox. It takes up 100Mb from he start, then, if I recall correctly, 300Mb more for updates, and it also needs about 100Mb of free space, supposedly outside virtual memory, on the main partition.

Could someone savy enough with these things explain what the fuck is going on here? I'm not familiar with scripting languages in the slightest, so I'm not sure if it's normal behaviour, but, what the hell.

Thanks in advance!


----------



## Ty Vulpine (Sep 9, 2008)

I'm lucky I can use Java at all, since it's "broken" on my IE, but not on Firefox...


----------



## Pi (Sep 9, 2008)

Java's not a scripting language.

It's got a fairly beefy standard library, though. That's probably the majority of it. And if you accidentally developed the SDK instead of just the runtime, you pulled down a bunch of extra building/compiling/debugging folderol.


----------



## Ty Vulpine (Sep 9, 2008)

Pi said:


> Java's not a scripting language.
> 
> It's got a fairly beefy standard library, though. That's probably the majority of it. And if you accidentally developed the SDK instead of just the runtime, you pulled down a bunch of extra building/compiling/debugging folderol.



The runtime enviroment is the problem on my computer. I've tried uninstalling and reinstalling Java, doesn't help. I've gone to Java's troubleshooting section on their website, and tried what they've suggested, but that doesn't help either.


----------



## CyberFoxx (Sep 9, 2008)

Hey, just be glad it only takes up that much. The IcedTea JDK requires 6GB of HD space just to compile it!


----------



## Pi (Sep 9, 2008)

TyVulpine said:


> The runtime enviroment is the problem on my computer. I've tried uninstalling and reinstalling Java, doesn't help. I've gone to Java's troubleshooting section on their website, and tried what they've suggested, but that doesn't help either.



Good for you, I guess.


----------



## Ty Vulpine (Sep 9, 2008)

Pi said:


> Good for you, I guess.



I was hoping for help, but expecting it from you is too much apparently. Then again, I guess I shouldn't have expected any.


----------



## Runefox (Sep 9, 2008)

With Java's official Java plugin, you can do a couple of things to reduce its footprint. If you go to the Control Panel, and then into Java, then under Temporary Internet Files, click Settings. The amount of space for temporary files is by default 1000MB; Make it 50MB. That should keep it from cluttering your hard drive. Back out of that window and go to the Advanced tab, then do the following: Under Miscellaneous, uncheck "Place Java icon in the system tray"; Under Java Console, choose "Do not start console". This should decrease the memory usage when the browser fires up Java.

Now, the reason why Java takes up so much memory and hard drive space is that it's actually a compiler. Java programs are downloaded to your PC and then compiled on-the-fly into code that your machine can understand. This is why Java is enabled on so many platforms, even cellular phones (because it can translate to their language, too). Unfortunately, this requires two things: For decent performance, both the compiler and the code must be loaded into your system RAM (and obviously so, too, must the compiled program be in memory), and performance will suffer in comparison to programs specifically built for your computer because of the extra steps involved.

Simplified, but basically how it works.

(by the way, Ty, your Java's probably broken due to the insane number of addons loaded into Internet Explorer, as seen in the screenshots you showed in the "Which Browser..." thread; You should try going into Internet Options, then the Programs tab, then the Manage Add-ons button. You might see it there, see if it's enabled or disabled, and enable it if it's disabled. If not, it's a problem with IE (it's corrupted)).


----------



## Ty Vulpine (Sep 9, 2008)

Runefox said:


> (by the way, Ty, your Java's probably broken due to the insane number of addons loaded into Internet Explorer, as seen in the screenshots you showed in the "Which Browser..." thread; You should try going into Internet Options, then the Programs tab, then the Manage Add-ons button. You might see it there, see if it's enabled or disabled, and enable it if it's disabled. If not, it's a problem with IE (it's corrupted)).



I did as you said, and did see that I have Java version 6 update 7 there, so I disabled all but one, but I still get the "Java Runtime Environment Cannot Load" error, and I try to download an "ActiveX Control" then get a "Several Java Virtual Machines running in the same program caused an error" message)
And I think it is my IE that's corrupted Java, because I also get an iexplorer error message saying something about a string of numbers/letters and that the "memory could not be read". (Or something like that)


----------



## Runefox (Sep 9, 2008)

It might be an idea to remove some of your IE add-ons (like the toolbars; Yahoo toolbar, Norton toolbar, etc - Do you use them? Remove the ones you don't use). You might also uninstall IE7 and reinstall it, or do a repair if it's an option (it's been a while).

Another thing to try would be to download Autoruns. Under the Internet Explorer tab, select and delete all the Java-related items. Then, reboot, uninstall and reinstall Java again. Might work. Also, delete anything with a "File not found" (it's not being loaded anyway).


----------



## Draco_2k (Sep 9, 2008)

Pi said:


> Java's not a scripting language.


Wurgh?



CyberFoxx said:


> Hey, just be glad it only takes up that much. The IcedTea JDK requires 6GB of HD space just to compile it!


Holy piss. Okay, I am now.



Runefox said:


> With Java's official Java plugin, you can do a couple of things to reduce its footprint. If you go to the Control Panel, and then into Java, then under Temporary Internet Files, click Settings. The amount of space for temporary files is by default 1000MB; Make it 50MB. That should keep it from cluttering your hard drive. Back out of that window and go to the Advanced tab, then do the following: Under Miscellaneous, uncheck "Place Java icon in the system tray"; Under Java Console, choose "Do not start console". This should decrease the memory usage when the browser fires up Java.
> 
> Now, the reason why Java takes up so much memory and hard drive space is that it's actually a compiler. Java programs are downloaded to your PC and then compiled on-the-fly into code that your machine can understand. This is why Java is enabled on so many platforms, even cellular phones (because it can translate to their language, too). Unfortunately, this requires two things: For decent performance, both the compiler and the code must be loaded into your system RAM (and obviously so, too, must the compiled program be in memory), and performance will suffer in comparison to programs specifically built for your computer because of the extra steps involved.
> 
> ...


Thanks a bunch!



Runefox said:


> *Now, the reason why Java takes up so much memory and hard drive space is that it's actually a compiler.*


Dear Lord, why would they do such a thing!? Surely there are other answers to compatibility stuff...


----------



## Runefox (Sep 9, 2008)

Well, it's not _entirely_ a compiler - At least, not by definition. Technically, the code is compiled into bytecode first, which is a sort of halfway point. The Java Virtual Machine still has to interpret the instructions and translate them to native code, but most computer-based Java plugins include a "Just-in-Time" compiler to recompile the bytecode to machine code. The interpretation method is even more processor intensive.

So traditionally and at the basic level, the Java Virtual Machine is slow; More or less an emulator. The Java Just-in-Time compiler is a dynamic recompiler.

... Either way you slice it, incredibly inefficient.


----------



## Pi (Sep 9, 2008)

Runefox said:


> Well, it's not _entirely_ a compiler blah blah bla




You clearly don't know what you're talking about


----------



## Eevee (Sep 9, 2008)

Runefox said:


> So traditionally and at the basic level, the Java Virtual Machine is slow; More or less an emulator. The Java Just-in-Time compiler is a dynamic recompiler.
> 
> ... Either way you slice it, incredibly inefficient.


exactly

the president of Sun woke up one day and said "how about we make Java use a JITC?  that's incredibly inefficient but it sounds like fun"

and javascript and perl are following suit because it's the trendy thing to do

not like *native code* runs faster than interpretation or anything


----------



## ArielMT (Sep 9, 2008)

Draco_2k said:


> Wurgh?



Java and JavaScript are completely unrelated.  JavaScript is a scripting language built in to your Web browser (if your browser supports it; the big four do), while Java is the virtual machine you're asking why takes up so much space.


----------



## Koda (Sep 10, 2008)

The 'Java' program directory in my Program Files folder has all the previous versions of JAVA run-time environment that were installed since.. probably the last time I reinstalled the OS. Looks like patches are treated as separate (and complete) installations in their own right. Taking up just under a half gig on my drive, and thats not including any configuration or crap it dumps in the browsers/windows directories.

Perhaps that's part of your problem. Try uninstalling the old versions, or deleting them outright. Ask yourself, do you really need JAVA anyway?

Just-in-time-compilation is a growing trend because as computers are getting faster, the neat little tricks programmers played at the machine language level waaaay back when are starting to not matter as much. Compilers are becoming increasingly complex, taking advantage of processor features like pipelines, speculative execution, unrolling loops... stuff most programmers wouldn't have time for (or even think about). 

Porting your entire programming language from one operating environment to another is tedious and time consuming. So, if you abstract away all the OS things, like file system, devices, memory, what-have-you, and run inside a virtual machine, you can execute the same program code and just plug it into the operating environment with a far smaller library than the whole kit'n'kaboodle. 

So, write a kick ass compiler for your language. Make it do funky shit to make it execute fast. Then, to maximize compatibility, invent your own sort of operating system wrapper. This gets written in some native language of that architecture. Now you have only 1 copy of the stuff that matters (the code people will write), and a hand full of smaller, OS/Arch wrappers which are easier to maintain and really won't change much.

Byte compiling is nice and all, but the only thing its really doing is taking 1 or 2 steps out of the whole process, its basically creating a symbol table and a tree structure of some kind, representing the program. This gets dumped into an evaluator/executor and you're done. I guess if you have really loooooong code, it will speed things up.. a little. At least with LISP, byte compiling allows the program to do tricks like continuation passing, and converting recursive crap to iterative loops.. So in those cases, its FAR better.

I don't think JITC languages will ever completely replace compiled languages, but they do have their usefulness and the performance gap is closing.


----------



## Pi (Sep 10, 2008)

Koda said:


> Byte compiling is nice and all, but the only thing its really doing is taking 1 or 2 steps out of the whole process, its basically creating a symbol table and a tree structure of some kind, representing the program. This gets dumped into an evaluator/executor and you're done. I guess if you have really loooooong code, it will speed things up.. a little. At least with LISP, byte compiling allows the program to do tricks like continuation passing, and converting recursive crap to iterative loops.. So in those cases, its FAR better.



Hi

my lisp implementation compiles everything to native code, but still handles CPS and tail-call optimization (which isn't even lisp-specific).

please try to learn what you're talking about before you talk about it.


----------

