Differences

This shows you the differences between two versions of the page.

Link to this comparison view

help:sysnews:java_system_tips [2011/09/22 13:43]
help:sysnews:java_system_tips [2011/09/22 13:43] (current)
Line 1: Line 1:
 +====== Java issues and tips ======
 +
 +
 +
 +===== Java remote method invocation problem =====
 +
 +Problem: When running a demo of Java's remote method invocation on our Ubuntu 9.04 based linux machines running java-6-openjdk the client could only attach to a server running on the same host.
 +
 +Solution: Professor Ellman discovered that the fix is to explicitly tell the server its hostname or IP address.  This is accomplished by adding ``-Djava.rmi.server.hostname=[IP or Name of HOST]`` to the java command when starting the server, so for a server named ``hopper`` with an IP address of ``10.0.0.63`` you can do either:
 +<code>java -Djava.rmi.server.hostname=hopper hellormi.HelloServer</code>
 +or                                                                                                                                                          
 +<code>java -Djava.rmi.server.hostname=10.0.0.63 hellormi.HelloServer</code>
 +both of which worked.
 +
 +Without specifing this option the server is only listening on the loopbak device.
 +
 +
 +===== Adding Java Web with Tomcat 6 to Netbeans 6.5  =====
 +Note: these instruction are for the setup in the Vassar College Computer Science Department Lab.  They may contain information not appropriate to an install elsewhere.
 +
 +==== 0) Overview ====
 +This setup will let you run your own tomcat webserver on the local machine for building and debugging apps in netbeans. There is one command to be typed in a terminal, all other steps will be preformed from within netbeans.  Total time to complete these steps will depend more upon download speed of the plugins than any other factor, but it seems to take under 10 min. from the Lab. These instruction were tested with netbeans 6.5 and tomcat 6 installed from apt-get in ubuntu 9.04.   
 +
 +
 +==== -) Create a local copy of the needed tomcat files  ====
 +  - open a terminal
 +  - enter the command 
 +<code>
 +  tomcat6-instance-create ~/mytomcat
 +</code>
 +
 +==== -) Open Netbeans ====
 +Netbeans can be invoked either by typing ``netbeans`` in a terminal, or by menu selection.  In Xfce4 it is on the ``Development`` menu.
 +
 +
 +=== -) Install Additional Plugins ===
 +You will need the plugins ``Java Web Applications`` and ``Tomcat``.
 +
 +Depending on what you have done with netbeans in the past, 
 +some or all the needed plugins may already be installed.  If you do not see one of the named plugins in the ``Available Plugins`` list, check the ``Installed`` tab.  If it is there you have that one already. 
 +
 +To get to the ``Available Plugins`` list, select 
 +
 +  - ``__T__ools`` --> ``Plu__g__ins`` --> ``Available Plugins``
 +  - Check [✔] ``Java Web Applications`` and ``Tomcat`` then select ``__I__nstall``
 +  - Once it installs the plugins it will prompt you to restart netbeans.
 +
 +{{sysnews:nb-tc-04.jpg|}}
 +
 +
 +=== -) Set up the Tomcat Server ===
 +When netbeans restarts, add the tomcat server. Select
 +
 +  - ``__T__ools`` --> ``__S__ervers`` --> ``__A__dd server`` --> ``Tomcat 6.0`` --> ``Next >``
 +  - Fill in ``__C__atalina Home:`` as  ??/usr/share/tomcat6?? 
 +  - Check (✔) the box for ``U__s__e Private Configuration Folder (Catalina Base)`` 
 +  - Fill that in with the name of the directory you created in the first step, you will need to give it the absolute path. (Replace ??YOUR_USER_NAME?? with //your user name//.) Enter ??/home/YOUR_USER_NAME/mytomcat??
 +  - Fill in something in the ``__U__sername`` and ``__P__assword`` fields.  It will create this user.  It stores the username and password in plain text in the file %%conf/tomcat-users.xml%% in your %%mytomcat%% directory, so don't use a valuable password.  If you forget it, you can look at in netbeans or get it from the file.
 +  - Check (✔) the box labeled ``Enable HTTP Monitor``
 +
 +When you select ``Close`` netbeans will save your server settings.
 +
 +
 +
 +==== You can now begin a project using your Tomcat server ====
 +To do this, select
 +
 +  - ``__F__ile`` -->  ``Ne__w__ Project`` 
 +  - in the column ``__C__ategories:`` select ``Java Web``
 +  - in the column ``__P__rojects:`` select ``Web Application``
 +  - select ``Next >``
 +  - Enter your ``Project __N__ame:`` or keep the default.
 +  - Enter your ``Project __L__ocation:`` or keep the default.
 +  - Select ``Next >``
 +  - for ``__S__erver:`` you should either see %%Tomcat 6.0%% or if you have used netbeans with other servers before, you will get a pull down list of servers you have already added.  If the latter, select %%Tomcat 6.0%%.
 +  - the rest of that page can be left at the default settings.  So, select ``__F__inish`` as the final step.
 +
 +===== Tomcat server can't start because one is already running on that port particular =====
 +There are two likly causes of this.  They each have a different solution.  If you have a server running you can stop it.  Sometimes, netbeans will think it has not started the tomcat server when it has.  That can lead to this problem.  If this happens, you must stop the server outside of netbeans (netbeans will not even give you the option so stop it as it does not think it is running).  To stop the server from the command line, use the %%shutdown.sh%% script in your %%mytomcat/bin%% directory:
 +
 +   ~/mytomcat/bin/shutdown.sh
 +
 +Should do it.  If it does not, then someone else has a server running.  If that is the case you should do two things, 
 +
 +  * Write me, tell me the name of the machine, the time of day and the ``Ser__v__er port`` listed when you look at the server properties (``__T__ools`` --> ``__S__ervers``)
 +  * Change your server to run on a different port.
 +    ``__T__ools`` --> ``__S__ervers`` --> ``Ser__v__er Port``, increment it a bit. ``Close``. See if that helps.
 + 
 +
 + --- //[[priestdo@cs.vassar.edu|Greg Priest-Dorman]] 2009/09/30 16:41//
 +
 +