Skip to main content
added 2 characters in body
Source Link
Beryllium
  • 13k
  • 11
  • 59
  • 88

Is it possible to get the name of the currently logged in user (windowsWindows/unixUnix) and the hostname of the machine.?

I assume it's just a property of some static environment class.

I've found this for the user name

com.sun.security.auth.module.NTSystem NTSystem = new com.sun.security.auth.module.NTSystem(); System.out.println(NTSystem.getName()); 

and this for the machine name:

import java.net.InetAddress; ... String computerName; ... try { computerName = InetAddress.getLocalHost().getHostName(); } catch(Exception ex) { ... } 

Is the first one just for windowsWindows?

andAnd what will the second one do, if you dontdon't have a hostname set?

Is it possible to get the name of the currently logged in user (windows/unix) and the hostname of the machine.

I assume it's just a property of some static environment class.

I've found this for the user name

com.sun.security.auth.module.NTSystem NTSystem = new com.sun.security.auth.module.NTSystem(); System.out.println(NTSystem.getName()); 

and this for the machine name:

import java.net.InetAddress; ... String computerName; ... try { computerName = InetAddress.getLocalHost().getHostName(); } catch(Exception ex) { ... } 

Is the first one just for windows?

and what will the second one do if you dont have a hostname set?

Is it possible to get the name of the currently logged in user (Windows/Unix) and the hostname of the machine?

I assume it's just a property of some static environment class.

I've found this for the user name

com.sun.security.auth.module.NTSystem NTSystem = new com.sun.security.auth.module.NTSystem(); System.out.println(NTSystem.getName()); 

and this for the machine name:

import java.net.InetAddress; ... String computerName; ... try { computerName = InetAddress.getLocalHost().getHostName(); } catch(Exception ex) { ... } 

Is the first one just for Windows?

And what will the second one do, if you don't have a hostname set?

Question Protected by Michael Petrotta

Is isit possible to get the name of the currently logged in user (windows/unix) and the hostname of the machine.

I assume it's just a property of some static environment class.

I've found this for the user name

com.sun.security.auth.module.NTSystem NTSystem = new com.sun.security.auth.module.NTSystem(); System.out.println(NTSystem.getName()); 

and this for the machine name:

import java.net.InetAddress; ... String computerName; ... try { computerName = InetAddress.getLocalHost().getHostName(); } catch(Exception ex) { ... } 

Is the first one just for windows?

and what will the 2ndsecond one do if you dont have a hostname set?

Is is possible to get the name of the currently logged in user (windows/unix) and the hostname of the machine.

I assume it's just a property of some static environment class.

I've found this for the user name

com.sun.security.auth.module.NTSystem NTSystem = new com.sun.security.auth.module.NTSystem(); System.out.println(NTSystem.getName()); 

and this for the machine name:

import java.net.InetAddress; ... String computerName; ... try { computerName = InetAddress.getLocalHost().getHostName(); } catch(Exception ex) { ... } 

Is the first one just for windows?

and what will the 2nd one do if you dont have a hostname set?

Is it possible to get the name of the currently logged in user (windows/unix) and the hostname of the machine.

I assume it's just a property of some static environment class.

I've found this for the user name

com.sun.security.auth.module.NTSystem NTSystem = new com.sun.security.auth.module.NTSystem(); System.out.println(NTSystem.getName()); 

and this for the machine name:

import java.net.InetAddress; ... String computerName; ... try { computerName = InetAddress.getLocalHost().getHostName(); } catch(Exception ex) { ... } 

Is the first one just for windows?

and what will the second one do if you dont have a hostname set?

added 548 characters in body
Source Link
Omar Kooheji
  • 55.9k
  • 71
  • 187
  • 243

Is is possible to get the name of the currently logged in user (windows/unix) and the hostname of the machine.

I assume it's just a property of some static environment class.

I've found this for the user name

com.sun.security.auth.module.NTSystem NTSystem = new com.sun.security.auth.module.NTSystem(); System.out.println(NTSystem.getName()); 

and this for the machine name:

import java.net.InetAddress; ... String computerName; ... try { computerName = InetAddress.getLocalHost().getHostName(); } catch(Exception ex) { ... } 

Is the first one just for windows?

and what will the 2nd one do if you dont have a hostname set?

Is is possible to get the name of the currently logged in user (windows/unix) and the hostname of the machine.

I assume it's just a property of some static environment class.

Is is possible to get the name of the currently logged in user (windows/unix) and the hostname of the machine.

I assume it's just a property of some static environment class.

I've found this for the user name

com.sun.security.auth.module.NTSystem NTSystem = new com.sun.security.auth.module.NTSystem(); System.out.println(NTSystem.getName()); 

and this for the machine name:

import java.net.InetAddress; ... String computerName; ... try { computerName = InetAddress.getLocalHost().getHostName(); } catch(Exception ex) { ... } 

Is the first one just for windows?

and what will the 2nd one do if you dont have a hostname set?

Source Link
Omar Kooheji
  • 55.9k
  • 71
  • 187
  • 243
Loading