Sun Java Solaris Communities My SDN Account Join SDN
 
Article

Doing Remote Development with Sun Studio Software

 
By Gordon Prieur and Ann Rice, August 2004, Revised April 2005  

Doing Remote Development with Sun Studio Software

In the past, most SunTM customers had a Sun workstation running the SolarisTM Operating System on their desktop. They could easily develop applications for deployment on other workstations or on large Sun servers. Today, many developers have a PC running Microsoft Windows on their desktop instead. How can these developers use Sun Studio software to develop their Solaris applications?

One way is to use the features provided by the VNC (Virtual Network Computing) software available from Real VNC Ltd.

The VNC product includes both server-side software and client-side software. To use VNC for remote development with Sun Studio software, a developer starts a VNC server session on a server running the Solaris OS or the Linux OS, and then starts a VNC viewer on his desktop to connect with the VNC server and run the Sun Studio software. The PC serves as a remote display of the Solaris or Linux server.

Getting and Installing VNC

The VNC software is freely downloadable from the RealVNC web site at http://www.realvnc.com. It is available for general use under the conditions of the GNU General Public License.

The authors of this article have used both VNC 4.0 and VNC 3.3.7. Our testing found fewer problems when we were running VNC 4.0 although we were able to complete our work with either version.

The download page includes both installable packages and source code. Download the installable packages and install them according to the instructions in the README file. You need VNC software both for the remote system and the desktop system.

To run a server on
and a viewer on
download
Solaris
Windows
Solaris 2.5 (SPARC) and Windows 9x /2000/NT/XP (x86)
Linux
Windows
Linux (x86) and Windows 9x /2000/NT/XP (x86)
Solaris
Linux
Solaris 2.5 (SPARC) and Linux (x86)
 

Don't forget to download the documentation package as as well as the software. This article is not intended as complete VNC documentation, and does not replace or supercede the documentation provided by RealVNC Ltd.

To build the VNC software from the source code, download the source code files and follow the instructions in the README file. You can build all of the client-side VNC software from these files. However, the VNC 4.0 source distribution no longer contains the sources to build the Xvnc server program, so you cannot build the complete server-side VNC software from the files available on the RealVNC web site. The README file does direct you to where to get the source files for the Xvnc program and how to build them.

Configuring Your VNC Software

You start a VNC session by running the vncserver program on the Solaris or Linux server. Although you don't have a viewport to this session until you start a VNC viewer, the VNC server starts programs running that persist until you end the session.

When you run the vncviewer program to start a VNC viewer, you open a viewport to the VNC session. You can start a VNC viewer, exit the viewer, and then start another viewer to rejoin the same VNC session at a later time. You can even go home and connect to your VNC session from a different desktop. If you have the Sun Studio software running when you exit the VNC viewer, it is still running when you reconnect to the VNC session with a new viewer.

Several programs are started when you run the vncserver program to start your VNC session. By default, the xterm terminal emulator and the twm window manager are started. Both of these programs are somewhat obsolete, and you may want better control over session startup. You can get this control by editing the file $HOME/.vnc/xstartup, which is created the first time you start a VNC session. Here are the contents of the xstartup file we use:

#! /bin/sh

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

if [ -r "$HOME/.vnc/Xresources.$VNCDESKTOP" ]
then
    xrdb -merge "$HOME/.vnc/Xresources.$VNCDESKTOP"
fi

xsetroot -solid blue

case "$VNCDESKTOP" in
X)
    xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
    twm &
    ;;

dt)
    dtterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
    dtwm &
    ;;

gnome)
    metacity &
    gnome-terminal --geometry 80x24+10+10 --title="$VNCDESKTOP Desktop" &
    ;;

ss)
    metacity &
    sunstudio -J-client &
    ;;
esac

The $VNCDESKTOP environment variable is set by the vncserver program before it runs the xstartup script. Its default value is X, but you can change the value with the -name option of the vncserver command. For example, the following command starts the metacity window manager and the gnome-terminal terminal emulator:

vncserver -name gnome

Many users won't want the choices the case statement in the xstartup file gives. You can modify the xstartup file to make the default session startup what you want. It is also useful to start a terminal emulator such as dtterm, gnome-terminal, or xterm as it simplifies starting other programs in your VNC session.

Starting and Ending a VNC Session

To start a session on the Solaris or Linux server, run the vncserver program. The first time you start a session you are asked for a password. The VNC server remembers this password and you don't need to supply it again. If your desktop is a Windows PC, you probably need to telnet to the Solaris server to start the vncserver program. When the vncserver program starts, it displays some startup information. The most important part of this information is the VNC server name, which is similar to a $DISPLAY variable you might use for X Windows applications.

To end your VNC session, use the vncserver command on your Solaris or Linux server, with the -kill option and display name. For example:

vncserver -kill foo:1

You can specify several options to the vncserver program when starting a VNC session. See the vncserver(1) man page for a complete list of options. If you have a display with 24-bit color, you might want to start a VNC session with the -depth 24. If your xstartup file contains several desktop models like the example xstartup file above, you need to specify the -name option to use one of the alternative desktop configurations.

Starting the VNC Viewer

To connect to your VNC session, run the vncviewer program from your PC. The VNC viewer needs to know the name of your VNC server, which is the name the VNC server returned when you started your VNC session. (The VNC server name is usually the name of your Solaris or Linux server followed by a colon and a number; for example, myhost:1. It might also include the domain name of your Solaris or Linux server.) You can also find the name in your $HOME/.vnc directory. You can specify the VNC server name as an argument to the vncviewer command. Or when the Connections Details dialog box is displayed, enter the display name in the Server text field and click OK. The VNC viewer asks you for the password you used when you started the VNC server. When you have entered the password, the VNC viewer display your VNC session.

You can specify several options to the vncviewer command. For a complete list of these options, see the vncviewer(1) man page.

Two of our favorite options are -FullScreen and -FullColor.

Maximizing Performance

Doing remote development with VNC has the drawback of offloading the JavaTM Virtual Machine (JVM) software from your desktop to the server. If many developers are running VNC concurrently, the server machine can become overloaded and suffer performance problems.

One solution is to run JVM software called the Java HotSpotTM Client VM (client VM). The VM software is typically started by the Java interpreter (java). The interpreter looks at system resources and starts either the Java HotSpot Server VM (server VM) or the client VM. The server VM uses more system resources than the client VM, so forcing the interpreter to use the client VM should minimize resource consumption.

To run the client VM with Sun Studio, include the -J-client in the sunstudio command:

    $ sunstudio -J-client

Note: The terms "Java Virtual Machine" and "JVM" mean a Virtual Machine for the Java(TM) platform.

Frequently Asked Questions

  1. Q: I have a 24-bit True Color display but my VNC sessions are started with fewer colors. Why is that?
    A: You need to start your VNC server with the -depth 24 option to be assured of 24-bit color.

  2. Q: When I start in the VNC viewer in full-screen mode, I get a black background in my VNC window and the actual display is much smaller than the window.
    A: In some cases you need to start your VNC session by using the -geometry option of the vncserver command to specify how wide your display really is. Try the following command, being sure to use the correct pixel width and height:
        vncserver -geometry 1280x1024
        
  3. Q: The first time I pressed the F8 key, the popup menu was displayed. Subsequent times that I pressed the key, the menu was not displayed. What can I do?
    A: We had this problem occasionally when testing with VNC 3.3.7. When we switched to VNC 4.0, the problem went away. Try upgrading to the latest release of VNC.

  4. Q: When I start the Sun Studio IDE from my VNC session I get the following warning. What does it mean?
    	Warning: Cannot convert string
    	"-monotype-ariel-regular-r-normal--*-140-*-*-p-*-iso8859-1"
    	to FontStruct
    	
    A: You can safely ignore this warning. It means a font wasn't found when you started the IDE. The IDE will use a different font so you shouldn't see any problems because of this warning.

  5. When I try to start my Mozilla or Netscape 7 browser from my VNC session, an alert box is displayed telling me my profile is in use. Why is this?
    A: Later versions of Netscape and all versions of Mozilla do not allow the sharing of a user's browser profile. If you are running the browser in another window or login session you cannot share it. This is a browser limitation, not a limitation of the VNC software or the Sun Studio IDE.
  6. Q: I killed a VNC server and then tried to start another VNC server with the same VNC server name, and received an error message. What should I do?
    A: We have seen this error message when using an older version of the VNC software (VNC 3.3.3). It does not occur with VNC 3.3.7 or VNC 4.0, so try upgrading to one of these versions. Also, be sure that the /tmp/.X11-pipe and /tmp/.X11-unix directories are writable.
  7. Q: Sometimes the remote server slows way down when multiple users are running the Sun Studio IDE on it. Is there a way to improve performance?
    A: Yes. The Sun Studio IDE starts up JVM software to run its Java code. There are actually two types of JVM software that can be run, the Java HotSpot Client VM (client VM) and the Java HotSpot Server VM (server VM). The Java interpreter (java) typically decides which JVM software to run by looking at system resources. Since servers are typically faster machines with lots of memory, the server VM is most likely the one chosen. So if you explicitly start the Sun Studio IDE and tell it to use the client VM, you save memory consumption on your server. To start the client VM, include the -J-client option in the sunstudio command:
    sunstudio -J-client
    
About the Authors

Gordon Prieur is the team lead for the Sun Studio Integrated Developement Environment (IDE). Gordon has worked on Sun's IDE tools for 7.5 years. Before coming to Sun, he worked on IDEs at Microtec Reasearch, Inc. and Pyramid Technologies.

Ann Rice is a staff writer in the Sun Studio Technical Documentation group, and is responsible for documenting the dbx debugger and the Sun Studio IDE. Ann began her career as a programmer. She has documented network technology and development tools, as well as serving as a technical publications manager for several Silicon Valley companies, including 3Com Corporation and Sybase, Inc. Ann is a past president of the Silicon Valley chapter of the Society for Technical Communication.

 
Rate and Review
Tell us what you think of the content of this page.
Excellent   Good   Fair   Poor  
Comments:
Your email address (no reply is possible without an address):
Sun Privacy Policy

Note: We are not able to respond to all submitted comments.