LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-14-2006, 02:12 PM   #1
halfpower
Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 241

Rep: Reputation: 31
What exactly is Java used for?


Java seems to be a popular language. I can't seem to figure out what it is being used for. Is it used outside web development? It seems like most applications are done in C and C++.
 
Old 09-14-2006, 02:55 PM   #2
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
Quote:
Originally Posted by halfpower
Java seems to be a popular language. I can't seem to figure out what it is being used for. Is it used outside web development? It seems like most applications are done in C and C++.
Java is used for everything. I mean it, everything. From applications running on cell phones and PDA's(J2ME), to server and client side applications because of its awesome networking capabilities. As servlets/jsp pages to generate dynamic pages. Currently, I'm working on a MP3/Ogg player written in Java. You can even bind Java to SDL/OpenGL and produce wonderful multimedia applications and games.

I think Java is much more used inside big corporations than, for example... open sourced applications.

We actually had a thread going on about Java:

http://www.linuxquestions.org/questi...d.php?t=414812

The title was "Why I hate Java", but it was still a good reading, nonetheless. The only reasons to not use Java that I can think of is: Writing really low level applications (such as drivers) or not knowing how to use Java.

You can read more about Java on Wikipedia:

Java (Sun):
http://en.wikipedia.org/wiki/Java_%28Sun%29

Java programming language:
http://en.wikipedia.org/wiki/Java_programming_language

Read also about the differences between Java Standard, Enterprise and Micro edition:

Standard:
http://en.wikipedia.org/wiki/Java_Pl...andard_Edition

Enterprise:
http://en.wikipedia.org/wiki/Java_Pl...rprise_Edition

Micro:
http://en.wikipedia.org/wiki/Java_Pl..._Micro_Edition
 
Old 09-14-2006, 02:55 PM   #3
Okie
Senior Member
 
Registered: Mar 2002
Location: Oklahoma
Posts: 1,154

Rep: Reputation: 187Reputation: 187
there is a lot java is used for, web browser plugins at places like http://www.jigzone.com/

and applications like Jgnash is a Java based accounting software http://jgnash.sourceforge.net/wiki/index.php/Main_Page

install and use Java a while, you would be suprised how much software is running on Java under the hood
 
Old 09-14-2006, 05:43 PM   #4
X.Cyclop
Member
 
Registered: Jun 2006
Location: Tlv
Distribution: Arch!
Posts: 120

Rep: Reputation: 21
Quote:
Originally Posted by halfpower
Java seems to be a popular language. I can't seem to figure out what it is being used for. Is it used outside web development? It seems like most applications are done in C and C++.
Java is used more for enterprise applications, but it's also on the web (mainly chats), desktop (RSSOwl and Eclipse are the best apps written in Java ) and mobile phones.
 
Old 09-14-2006, 05:50 PM   #5
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 52
C is faster than C++ and Java so when you application is too CPU intensive(huge graphics manipulation,etc.) it might be better to use C. Nowadays computers are fast enough(1 or 2Gb of ram and 3ghz for the cpu).
 
Old 09-19-2006, 05:25 AM   #6
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
Quote:
Originally Posted by halfpower
I can't seem to figure out what it is being used for.
mainly for filling up RAM

java.lang.HowMuchMoreBloodyMemoryMustiPurchaseException
 
Old 09-19-2006, 11:12 AM   #7
Poison [BLX]
LQ Newbie
 
Registered: Sep 2006
Location: WVU
Distribution: Slackware, Gentoo, LFS, DSL
Posts: 2

Rep: Reputation: 0
Quote:
Originally Posted by bigearsbilly
mainly for filling up RAM

java.lang.HowMuchMoreBloodyMemoryMustiPurchaseException
(heh ... true ...)

----

In response to the real question, however ....

Java is generally used for in-house applications because it provides near-seamless networking, relatively easy to set up database interfaces, decent error (err, exception ) handling, and otherwise unmatchable portability, though that portability comes at the cost of running on top of what is essentially an emulator for a nonexistent platform, aka the Java Virtual Machine, as provided by the Java Runtime Environment.

It tends to be slower than C because C is completely compiled to run on the native system, so it has to be recompiled to run on any other hardware and/or OS platform, as well as having modifications in the source before that is even possible. Java is designed to be written once and run anywhere, meaning I can write it on my Slackware box, compile it to a .class, drop it onto a Windows computer, run it there, and then throw it out onto a Solaris box, and run it there too, all without worrying about having to recompile anything.

It's good for what it's for, but you can never base an OS on it, where with C ... every *nix based OS I've ever learned anything about is built on C. Java takes away a lot of the power C and C++ gives in order to avoid a large number of the common mistakes that are made when using that power, most notable is the difference of 'Pointers' (C/C++) and 'References' (Java) ... pointers give direct access to the address of the memory segment used by something, a Reference just passes along the entire object, without making a copy in memory, essentially hiding all of the raw memory access from the programmer. Just one of the many little things that makes well written C noticably faster.

Because of this, most things that are going to be distributed, and especially sold, are written in a lower level language like C/C++. But for an application that is going to be a frontend for, let's say, clock-in/clock-out operations, providing employee viewable timesheets, and auditing of the system, especially if a web-based system is preferred, Java is likely a very good solution.
 
Old 09-19-2006, 12:38 PM   #8
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
like was mentioned java is used for lots of things. a big selling point for java is how fast and easy it writes, it *is* easier to program in java than in C++. the business world likes this because a java programmer is cheaper than a C++ programmer, and there are lots more of them to choose from.. as far as speed goes, there is a difference. how much exaclty? that will vary greatly depending on lots and lots of things (usually the person doing the benchmarking).. everybody gets very caught up in the speed of an application, very often though the final speed of the app is not important, it is much more importatnt to get a stable, portable product to market quickly. this is where java shines. many times there are plenty of extra cpu cycles left over, so you dont need to get that last little drop of optimization from a compiled language..

and of course there are other applications where speed is extremely important. such as your 3d games, and multimedia type apps. java will have to improve a great deal to break into these areas, and at this time it is not able to keep up with a compiled lang.

java has a bad rep about many things especially memory usage. many of these are myths, and if they are fact they are hanging around from earlier versions of java. there have been some major improvements to java in the past couple releases. typically now if you are having probems, it is not a java fault, it is the result of bad programming (maybe not bad, but probably not doing it the Java way).

btw, i am primarily a C and C++ programmer (at work and hobby), but i would strongly suggest learning java. and in my experience, programming in java will often make your C++ better.
 
Old 09-20-2006, 09:47 AM   #9
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
Quote:
Originally Posted by xhi
and in my experience, programming in java will often make your C++ better.
I'll second that. Usually knowing some programming language X and subsequently learning some other language Y will make you better programming in X. (Especially if you're like me and your primary learning style is comparison-oriented.)

After a couple years of hating Java, I eventually came to realise that it has its place. Sure, I don't care for it, but I also don't do a lot of stuff that Java is usually used for (the so-called "enterprise" applications, huge services connecting hundreds of users, etc). Because of the nature of my typical program, dynamic languages suit me best. But learning Java has provided another image of how languages could be designed and could work; that has been the real value of Java to me.
 
Old 09-20-2006, 10:03 AM   #10
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
it's all fashion.

project manager X has no idea how to code but hears
everyone uses wotsit-oriented "newlingo" (with XML)
and he went to a conference about it
so we all have to get in on it whether it's the best tool for the
job or not.

So we build a big monolithic app. instead of something where a collection of small scripts
chained together will probably work just as well, probably be faster and
be much much easier to maintain, easier to read, debug and add new features to.

or am I a cynic
 
Old 09-20-2006, 10:26 AM   #11
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
Quote:
Originally Posted by bigearsbilly
it's all fashion.

project manager X has no idea how to code but hears
everyone uses wotsit-oriented "newlingo" (with XML)
and he went to a conference about it
so we all have to get in on it whether it's the best tool for the
job or not.

So we build a big monolithic app. instead of something where a collection of small scripts
chained together will probably work just as well, probably be faster and
be much much easier to maintain, easier to read, debug and add new features to.

or am I a cynic
wotsit-oriented "newlingo" uses XML? then it must be good! ill take all the licenses you have!
 
Old 09-22-2006, 08:40 PM   #12
halfpower
Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 241

Original Poster
Rep: Reputation: 31
Exactly what type of programs would need to be run on any platform? I have a C++ book within arms reach and all the code in it will compile on just about any platform. Wouldn't that essentially make C++ platform independent as well? I can't code a GUI, but most algorithms will run okay.
 
Old 09-23-2006, 02:48 AM   #13
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
Quote:
Originally Posted by halfpower
Exactly what type of programs would need to be run on any platform? I have a C++ book within arms reach and all the code in it will compile on just about any platform. Wouldn't that essentially make C++ platform independent as well? I can't code a GUI, but most algorithms will run okay.
C++(the "language" or the "syntax") is basically platform independent. That is correct. The binary files that the compiler generates are not, as you probably already know(ex: running a Windows exe in Linux). Java, on the other hand is platform independent: You can just take your compiled .class file and it will run in any other environment where the JVM is available.

Also, keep in mind that your code won't always compile on different compilers. I remember reading my first C++ book: Teach yourself C++ in 21 days. It was an ok book (for a first book, that is) and the author made a lot of system("pause") calls so that while running the programs, the user could actually "pause" the program in order to see what is happening. Very important for a beginner in a Windows environment, who most likely can't use the console: If you double click on a hello_world.exe in Windows the screen will simply flash.

Anyway, the system("pause") was not available in the gcc compiler and I was having a hard time figuring out why I could not compile that simple crappy program in Linux. This brings C++ portability even further down: You are not only dependent on the platform you are coding for, but you will also have to deal with compilers specific libraries (or lack of those), whereas Java shines across platforms in a robust, portable and secure OOP way.

And to answer your question:

"Exactly what type of programs would need to be run on any platform?"

For me, every program should run, at very least, on the major OS out there (MacOS, Windows and Linux at least). Just think for an end user how great it would be to go to a game store and pick any game there, knowing it would run on any OS you run at home. Now think about huge companies who want to cut down the budget by changing from Windows OS to Linux: This simple task would most likely cost them even more if all their programs are turned useless or need to be re-written from scratch. Have them been written in Java, this would not be an issue. Think also how nice it would be for a casual user who loves Amarok, but also needs to use Windows, to be able to run Amarok in his Windows machine. If that was written in Java, there should be no problems.

Bottom line is, C is far from being portable. Even when a program is ported from one OS to another it usually blows. Take Gimp for example. Gimp is without a doubt, my favorite program under Linux. To this date, I can't believe such a quality program is free. Try installing Gimp for windows + GTK RE and you are in for the worst ride with the most buggy program ever made. Gimp in Windows will crash so much, so often, that is making me save money for photoshop, since I just have to use Windows...

And much, much more. Viva Java ^_^;;

Last edited by Mega Man X; 09-23-2006 at 08:48 AM.
 
Old 09-23-2006, 10:48 AM   #14
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
well, that definately sounds like a synopsis of c portability from a non c programmer.

but your java points are correct. java classes are able to be used in different platforms without a recompile. this makes it nice if you do not know how, or do not have time to make c code builds for each platform.

i would argue strongly against about your c portability claims though. c runs on everything, and it has been doing that for longer than the word java has been spoken. its just a matter of knowing how to do it.

i get tired of hearing people say that java is slow, or c leaks memory.. its not the languages people, its poor programming skills.
 
Old 09-24-2006, 06:05 PM   #15
slantoflight
Member
 
Registered: Aug 2005
Distribution: Smoothwall
Posts: 283
Blog Entries: 3

Rep: Reputation: 35
Quote:
Originally Posted by Mega Man X
Bottom line is, C is far from being portable. Even when a program is ported from one OS to another it usually blows. Take Gimp for example. Gimp is without a doubt, my favorite program under Linux. To this date, I can't believe such a quality program is free. Try installing Gimp for windows + GTK RE and you are in for the worst ride with the most buggy program ever made. Gimp in Windows will crash so much, so often, that is making me save money for photoshop, since I just have to use Windows...

And much, much more. Viva Java ^_^;;
My personal experience with Gimp on Windows and other people I know, has been sastifactory. Have'nt experience any the aforementioned bugs you've been describing. Perhaps this is something they fixed in a later release. Regardless, you're example is still invalid even if it were true, especially with the success of cross-platform programs like Firefox. And I supposed I don't even need to mention Linux, which outside ASM bootstraps is written completely in C and portable to many different archictectures. However if you need some commercials examples look no further than apple. They've just ported their operating system to a different CPU. And on top of that, all or nearly all their old programs still run. Their professional apps now all have intel binaries.
Other well known apps that have been ported to other operating systems, using the beauty of C/C++.

VMWARE
Maya
Microsoft Office even
and ofcourse the list continues.

C is very portable. In fact its even more portable than Java. Which only has support for a relatively small number of platforms. Compared to C anyways. Plus you're relying on proprietary implementation. It might be a very a good implementation. But nothing is flawless. You can't choose how your java program decides to interact with platform, unless you make your own external C libraries. Which brings me back to my first point. C is very portable.

Given C's power, portability, and speed, I'd much rather be a masterful C programmer than a masterful Java programmer. Even as a language, I find java is too remeniscient of C++. Outside of the convenient libraries, and memory management, I might as well be using c++. So I for one will not be saying viva la Java.

Last edited by slantoflight; 09-24-2006 at 06:09 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Java plugin installed correctly for Firefox but not able to view any java applet tvn Linux - Software 10 04-15-2010 02:13 AM
Firefox refuses to load Java jnlp files - plugin and java ok Melsync Linux - Software 1 06-25-2006 04:09 PM
Synaptic Package Manager shows 'java-common' and 'java-gcj-compat' as Installed. swiadek Ubuntu 3 02-12-2006 11:54 AM
JAVA JRE installation to view java applet through browser dipenchaudhary Linux - Software 1 01-23-2006 09:20 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration