Getting Started with Java on Linux
This little tutorial has gotten you started with your Java adventure on Linux. Using Resin as your web and application server gives you all the possibilities that the not-so-cheap alternatives do, including XML/XSL processing, JSP/Servlet support and load balancing. If you choose Resin-EE, you also receive EJB (Enterprise Java Beans). For a detailed description of what you are allowed to do with Resin, read the Caucho Developer Source License. It comes with your Resin installation, in /usr/local/resin/LICENSE.
Resin also offers almost endless tweaking possibilities, which can be used to configure the functions of your server and also to improve performance in some setups. The complete Resin configuration reference can be found at www.caucho.com/resin/ref/config.xtp.
If you have no plans to use Java for web development, you still have a working Java development environment for standalone applications. A good starting point for all Java programming is java.sun.com/docs. There you'll find the complete standard API reference, as well as documentation on other interesting Java technologies, including APIs for programming 3D, SSL, Speech and others.
email: daniel@solin.org
- « first
- ‹ previous
- 1
- 2
- 3
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
- New Products
- Linux Systems Administrator
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- Web & UI Developer (JavaScript & j Query)
- Designing Electronics with Linux
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- Nice article, thanks for the
9 hours 51 min ago - I once had a better way I
15 hours 37 min ago - Not only you I too assumed
15 hours 55 min ago - another very interesting
17 hours 48 min ago - Reply to comment | Linux Journal
19 hours 41 min ago - Reply to comment | Linux Journal
1 day 2 hours ago - Reply to comment | Linux Journal
1 day 2 hours ago - Favorite (and easily brute-forced) pw's
1 day 4 hours ago - Have you tried Boxen? It's a
1 day 10 hours ago - seo services in india
1 day 15 hours ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?



Comments
Re: Getting Started with Java on Linux
i am getting such result after typing javac at home directory
kindly , give me some solution for the problem
[jdk1_3_1_12 is stored in /usr/local]
/usr/local/jdk1.3.1_12/bin/i386/native_threads/javac: error while loading shared libraries: libstdc++-libc6.1-1.so.2: cannot open shared objectfile: No such file or directory
[root@localhost home]#
may be you should store at
may be you should store at ./usr/local/jdk
I think you don't have file l
I think you don't have file libstdc....... Try to find some .rpm that contains that file. I had the same problem, but I don't remember name of the .rpm.
Re: Getting Started with Java on Linux
I really Donot know about this! sorry
Re: Getting Started with Java on Linux
me too....somebody please help..
Re: Getting Started with Java on Linux
This document has two parts. The first explains how to install just the Java software development kit. The second part explains how to install the Sun One Studio (previously known as Forte). This is how it worked for me. Any risk in using this information is yours (don't whine to me, I ain't got no money anyway).
How to install Java JDK:
1. Decide on a directory to hold the jdk folder (I used /usr/local) and change to it using:
linux:~# cd /usr/local
2. Download the "j2sdk-1_4_1_01-linux-i586.bin" from ww.java.sun.com into the current directory.
3. Change the permisions on the file using:
linux:/usr/local# chmod 755 j2sdk-1_4_1_01-linux-i586.bin
4. Run the binary:
linux:/usr/local# j2sdk-1_4_1_01-linux-i586.bin
. This will create a new subdirectory, j2sdk-1_4_1_01, and install the sdk into it after you have scrolled through the license agreement and answered "yes" to "Do you agree to the above license terms? [yes or no]"
5. Enter:
linux:/usr/local# ln -s /usr/local/j2sdk-1_4_1_01 /usr/local/jdk
This creates a symbolic link, /usr/local/jdk, to the j2sdk-1_4_1_01 directory. This way you can have the jdk directory in the path, and upgrade your versions merely by installing it to its own directory and then changing the symbolic link again.
6. Append to /etc/profile:
export PATH=$PATH:/usr/local/jdk/bin
to make sure the /usr/local/jkd/bin directory (but really the
/usr/local/j2sdk-1_4_1_01/bin directory ) is in your path.
7. Reload the /etc/profile by:
linux:~# source /etc/profile
8. Enter
linux:~# javac
to check that it is properly installed.
9. Append to /etc/profile:
export JAVA_HOME=/usr/local/jdk
to tell your system where the JDK base directory can be found.
How To Install Sun One Studio:
1. Download the "j2sdk-1_4_1-s1studio_ce-rul-bin-linux.bin" file. Make sure downloaded file is the same size as indicated on the Sun web page.
2. To change permisions run:
linux:~# chmod 777 j2sdk-1_4_1-s1studio_ce-rul-bin-linux.bin
3. Decide on a directory( eg. /usr/local).
4. Run:
linux:~# chmod 777 j2sdk-1_4_1-s1studio_ce-rul-bin-linux.bin
The installer will start up, ask if you agree to the license terms, and if you say yes, it will ask which directory to install to (I chose /usr/local/s1studio4_1_1). There is no need to be currently in that particluar directory at the time. It will create a new directory tree in /usr/local/s1studio4_1_1 with subdirectories _uninst, j2sdk1.4.1, and s1studio.
5. The installer will put focus on the finish button when it's done. When you press it, a small message box comes up saying that to start the program, you must run runide.sh in /~/s1studio/bin to start the IDE.
6. If you HAVE NOT previously installed the jdk then append to '/etc/profile':
export PATH=$PATH:/usr/local/s1studio4_1_1/j2sdk1.4.1/bin
If you HAVE previously installed the jdk but want to use the new one, then edit '/etc/profile' to remove the export PATH line that contains your old jdk or j2sdk directory and append the new export PATH command to the profile file.
7. Append the next line to /etc/profile:
export PATH=$PATH:/usr/local/s1studio4_1_1/s1studio/bin
Save profile and exit the editor.
8. Reload the /etc/profile by:
linux:~# source /etc/profile
9. The only way I figured the following out, was by reading the runide.sh file. I found no documentation, no hint or clue elsewhere.
To start the IDE, runide.sh needs to know where the jdk is. The installation leaves it no clue, so you have to pass it a command line argument as shown:
runide.sh -jdkhome /usr/local/jdk
or
runide.sh -jdkhome /usr/local/s1studio4_1_1/j2sdk1.4.1
depending on your choice in part 6.
10. The easiest way I found to get the ide to start was to right-click the mouse on the KDE panel, then click on Add in the menu that pops up. On the next sub-menu click on SpecialButton, and next on Non-KDE Application. This will bring up a file selection box. Browse until you find the runide.sh file, and click on it. This will come up with a Non-KDE Application Configuration data-entry box. In the edit field, enter: -jdkhome /usr/local/jdk. You can click on the icon now to change it, or you can change it at any later time by simply right-clicking the icon on the panel to edit the preferences.
At this point I had an icon on the panel which I could left-click on to start the IDE.
Ron Gesell
Jan 28, 2003
Re: Getting Started with Java on Linux
sorry.. just want to ask how to run java applet(yahoo chess applet) on linux(rh9)
i had already install j2sdk1.4.1.02
i follow all the step above(i manage to compile java prog)... but still can open yahoo chess applet...
what else should i install
or should i install j2re?
just begin to know linux..
I think there is an error
I think there maybe an error in the tute. Although I am a beginner, so maybe I'm mistaken
towards the top there is the command :
mv j2sdk-1_4_0_01-linux-i586.bin /usr/local
I think that this is wrong and in fact should be
mv j2sdk-1_4_0_01 /usr/local
What the point in moving the .bin ?
please correct me If Im wrong but beginners like me try to follow the commands exactly and this is confusing
2cj2
Re: I think there is an error
Yes Its me again
I believe that I was correct before. Also I need to know how to set the path name when Im not in root. These couple of points would I feel be of great benefit in what is a great tutorial !
2cj2
Not The Error!!!!!!!
Hey dude.. its not Error as we have to move .bin file to /usr/local directory... Its the name of that package for Linux so its same if write jdk_1_4_0 or jdk_...bin ok by by... Correct me if I'm wrong anyway...
Re: Getting Started with Java on Linux
Nice Java Intro.
But -- Resin is not an application server, Resin is a servlet-engine. And -- Linux being open source and all, why not choose an open source appserver for the example? JBoss or Jonas anyone?
Re: Getting Started with Java on Linux
Why use reflection to get the length of an array?
Every array instance has a member .length ....
Re: Getting Started with Java on Linux
yeah, funny. maybe he likes reflecting
this works just as well....
class Test
{
public static void main( String argv[] )
{
System.out.println( "Arguments:" );
int i = 0;
while( i < argv.length )
{
System.out.println( argv[i] );
i++;
}
}
}
Re: Getting Started with Java on Linux
Haha.... Yeah, well, I'm a little mystery, I guess :)
Getting started with Tomcat instead of Resin
Just in case someone wants to try out Tomcat instead of Resin, here is a quick&dirty summary:
Download Tomcat binary from jakarta.apache.org
Unpack the binary (I unpack mine in /usr/local
Start tomcat by running /usr/local/jakarta-tomcat-4.0.4/bin/startup.sh
You may need to set the JAVA_HOME environment variable to point to your Java directory before Tomcat will start.
By default, Tomcat starts on port 8080. If you want to change it, edit the server.xml file in /usr/local/jakarta-tomcat-4.0.4/conf. (Just search for port="8080")
When you create the test JSP, put it in /usr/local/jakarta-tomcat/webapps/ROOT.
The URL should be http://localhost:8080/test.jsp?par=mysecretvalue
The Tomcat installation comes with documentation, just point your browser to http://localhost:8080 and you should get the main page for your installation, with links to the docs. If you have JDK 1.4, it is easy to enable SSL with Tomcat as well.
Re: Getting started with Tomcat instead of Resin
Currently I've got tomcat running on port 8080, but would like to be able to run it with apache on port 80. So, has anyone able to get it to work with apache? If so what kind of connector did you use and what are the steps?
Re: Getting Started with Java on Linux
Why use Resin ? Jakarta Tomcat is mature, free, and FREE product.
nedim
Re: Getting Started with Java on Linux
This document has two parts. The first explains how to install just the Java software development kit. The second part explains how to install the Sun One Studio (previously known as Forte). This is how it worked for me. Any risk in using this information is yours (don't whine to me, I ain't got no money anyway).
How to install Java JDK:
1. Decide on a directory to hold the jdk folder (I used /usr/local) and change
to it using:
linux:~# cd /usr/local
2. Download the "j2sdk-1_4_1_01-linux-i586.bin" from www.java.sun.com into the
current directory.
3. Change the permisions on the file using:
linux:/usr/local# chmod 755 j2sdk-1_4_1_01-linux-i586.bin
4. Run the binary:
linux:/usr/local# j2sdk-1_4_1_01-linux-i586.bin
. This will create a new subdirectory, j2sdk-1_4_1_01, and install the sdk
into it after you have scrolled through the license agreement and answered
"yes" to "Do you agree to the above license terms? [yes or no]"
5. Enter:
linux:/usr/local# ln -s /usr/local/j2sdk-1_4_1_01 /usr/local/jdk
This creates a symbolic link, /usr/local/jdk, to the j2sdk-1_4_1_01
directory. This way you can have the jdk directory in the path, and
upgrade your versions merely by installing it to its own directory and then
changing the symbolic link again.
6. Append to /etc/profile:
export PATH=$PATH:/usr/local/jdk/bin
to make sure the /usr/local/jkd/bin directory (but really the
/usr/local/j2sdk-1_4_1_01/bin directory ) is in your path.
7. Reload the /etc/profile by:
linux:~# source /etc/profile
8. Enter
linux:~# javac
to check that it is properly installed.
9. Append to /etc/profile:
export JAVA_HOME=/usr/local/jdk
to tell your system where the JDK base directory can be found.
How To Install Sun One Studio:
1. Download the "j2sdk-1_4_1-s1studio_ce-rul-bin-linux.bin" file. Make sure
downloaded file is the same size as indicated on the Sun web page.
2. To change permisions run:
linux:~# chmod 777 j2sdk-1_4_1-s1studio_ce-rul-bin-linux.bin
3. Decide on a directory( eg. /usr/local).
4. Run:
linux:~# chmod 777 j2sdk-1_4_1-s1studio_ce-rul-bin-linux.bin
The installer will start up, ask if you agree to the license terms, and if
you say yes, it will ask which directory to install to (I chose
/usr/local/s1studio4_1_1). There is no need to be currently in that
particluar directory at the time. It will create a new directory tree in
/usr/local/s1studio4_1_1 with subdirectories _uninst, j2sdk1.4.1, and
s1studio.
5. The installer will put focus on the finish button when it's done. When you
press it, a small message box comes up saying that to start the program, you
must run runide.sh in /~/s1studio/bin to start the IDE.
6. If you HAVE NOT previously installed the jdk then append to '/etc/profile':
export PATH=$PATH:/usr/local/s1studio4_1_1/j2sdk1.4.1/bin
If you HAVE previously installed the jdk but want to use the new one, then edit '/etc/profile' to remove the export PATH line that contains your old jdk or j2sdk directory and append the new export PATH command to the profile file.
7. Append the next line to /etc/profile:
export PATH=$PATH:/usr/local/s1studio4_1_1/s1studio/bin
Save profile and exit the editor.
8. Reload the /etc/profile by:
linux:~# source /etc/profile
9. The only way I figured the following out, was by reading the runide.sh file. I found no documentation, no hint or clue elsewhere.
To start the IDE, runide.sh needs to know where the jdk is. The installation leaves it no clue, so you have to pass it a command line argument as shown:
runide.sh -jdkhome /usr/local/jdk
or
runide.sh -jdkhome /usr/local/s1studio4_1_1/j2sdk1.4.1
depending on your choice in part 6.
10. The easiest way I found to get the ide to start was to right-click the mouse on the KDE panel, then click on Add in the menu that pops up. On the next sub-menu click on SpecialButton, and next on Non-KDE Application. This will bring up a file selection box. Browse until you find the runide.sh file, and click on it. This will come up with a Non-KDE Application Configuration data-entry box. In the edit field, enter: -jdkhome /usr/local/jdk. You can click on the icon now to change it, or you can change it at any later time by simply right-clicking the icon on the panel to edit the preferences.
At this point I had an icon on the panel which I could left-click on to start the IDE.
Ron Gesell
Jan 28, 2003
Re: Getting Started with Java on Linux
Because Tomcat is rubbish. Resin is not that expensive that the licenses price you out of running it, hell, if you're a small company and cant afford it, Caucho will let you off the hook! Go read the license terms.
Seriously, Tomcat is complete rubbish, its slow and cumbersome, and it crashes all the time. Resin is king! Long live resin!
Re: Getting Started with Java on Linux
The above is obviously a troll and should be ignored. Probably a Resin employee giving out dubious advice.
Tomcat is deployed at large companies due to its high regard by the programmers who's jobs would be affected if it wasn't stable. I'll even name one: Universal Studios. Its filling niches where traditional proprietary costs would be prohibitive or overkill.
Its solid, has open source backing (no small thing when you consider the resources this fact brings to bear), and its Free (as in Freedom, not free beer) to use as you please on as many boxen as you please.
And, one final very important point made by another poster here. When the company that makes Resin is long gone, Tomcat will still be there due to its status as an Open Source project. How's THAT for reliability.
Re: Getting Started with Java on Linux
Because Resin is much faster, it automagically reloads the web application when you change a class or the web.xml, etc.
Resin is free for development, you only have to pay a license for your deployment server.
Re: Getting Started with Java on Linux
Because
* Resin is much faster
Give them time, besides, speed isn't everything
* it automagically reloads the web application when you change a class or the web.xml, etc.
Yes, even tomcat does this
* Resin is free for development, you only have to pay a license for your deployment server.
Interestingly enough, aside from the damned sun java requirement, tomcat gives you:
- freedom to use it for whatever purpose,
- freedom to maintain it even if the vendor no longer does,
- freedom to install in as many machines with as many cpus as you wish,
- freedom to resell improved copies (or even giving them away gratis)...
With all of this and you not even have to pay for a license per machine/cpu for your deployment servers... so, tell us again, please, why should an enterprise use resin instead of tomcat?