Index: /issm/trunk-jpl/src/m/os/oshostname.m
===================================================================
--- /issm/trunk-jpl/src/m/os/oshostname.m	(revision 22055)
+++ /issm/trunk-jpl/src/m/os/oshostname.m	(revision 22056)
@@ -5,10 +5,21 @@
 %      hostname=oshostname();
 
-%See http://www.mathworks.com/help/matlab/ref/system.html "tips" section
-%We need to add < /dev/null otherwise what is in the clipboard is added
-[status,hostname]=system('hostname < /dev/null');
+%Initialize output
+hostname = '';
 
-% If that command did not work, we have an alternative
-if status~=0,
+%First try using java (most stable way)
+if usejava('jvm'),
+	hostname = char(getHostName(java.net.InetAddress.getLocalHost));
+end
+
+%Method 2: use system command (MATLAB bug includes what's in the clipboard)
+if isempty(hostname),
+	%See http://www.mathworks.com/help/matlab/ref/system.html "tips" section
+	%We need to add < /dev/null otherwise what is in the clipboard is added
+	[status,hostname]=system('hostname < /dev/null');
+end
+
+%Method 3, last chance
+if isempty(hostname),
 	if ispc
 		hostname = getenv('COMPUTERNAME');
@@ -16,9 +27,4 @@
 		hostname = getenv('HOSTNAME');
 	end
-end
-
-% one more try using java....
-if isempty(hostname) & usejava('jvm'),
-	hostname = char(getHostName(java.net.InetAddress.getLocalHost));
 end
 
