API to get computer name

i want to get computer name in Java program. I tried to use System.getProperty(), but seems like there is no appropriate key.
please advise. thanks!!

Here's some different ways using java.net package to get various names and numbers. Of course, this requires a network id.
import java.net.*;
public class GetIPAddress {
    public static void main(String[] args) throws UnknownHostException {
        System.out.println(InetAddress.getLocalHost());
        System.out.println(InetAddress.getLocalHost().getHostName());
        System.out.println(InetAddress.getLocalHost().getHostAddress());
        System.out.println
            ("+++ If there is more than 1 IP address for HostName +++");
        InetAddress[] inet = InetAddress.getAllByName(InetAddress.getLocalHost().getHostAddress());
        for (int x = 0; x < inet.length; x++)
            System.out.println
                ("IP " + (x + 1) + ": " + inet[x].toString().substring(1));
}The following one takes an IP address argument.
import java.net.*;
public class GetIPName
    public static void main(String[] args)
        try
            // Look up ip address, eg 123.123.123.123
            InetAddress local = InetAddress.getByName(args[0]);
            System.out.println(local.getHostAddress());
            System.out.println(local.getHostName());
            System.out.println(local.getCanonicalHostName());
        catch(Exception e)
            e.printStackTrace();
}

Similar Messages

  • Get Computer Name

    I think there was a VI
    'Get computer name'
    somewhere in the GToolbox (or former LVutil).
    I cannot find it - any hints?
    I need the name of the computer the program works on because it
    communicates with another application via TCP/IP and I would like to set
    the standard application adress as the local PC.
    Thanks
    Urs Bögli

    Luca,
    that's fine, an easy solution but hard to find !
    Attached is my VI now.
    Thanks
    Urs
    Luca P. schrieb:
    >Hello Urs,
    >
    >An easy way is to use the "string to IP" wired to the "IP to string"
    >VI (TCP palette). The IP to string function has a boolean input where
    >you can define if you want to see the IP address or the machine name
    >of the PC.
    >
    >Regards,
    >Luca
    >
    Attachments:
    PCsName.vi ‏9 KB

  • Get Computer name and move

    Hi all ,
    i need help with small problem ,
    i tried to create new script that know get all computer names that start with " ISR..." And then move them to another ou ,
    i have 2 convention name on my organization name  , 1 - ISR , 2 -TLV  . 
    some computers :
    ISR2
    ISR3
    ISR4
    some computers :
    TLV2
    TLV3
    TLV3
     i tried this command "
    Get-ADComputer -Filter * {Name -Like "TLV,"}  Error :
    Get-ADComputer : A positional parameter cannot be found that accepts argument 'Name -Like "TLV"'.
    At line:1 char:15
    + Get-ADComputer <<<<  -Filter * {Name -Like "TLV"}
        + CategoryInfo          : InvalidArgument: (:) [Get-ADComputer], ParameterBindingException
        + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.GetADComputer
    or if have another option -command can read both computers name and then move them
    My Website:www.Pelegit.co.il Mcitp /Mcsa 2012

    Lol , My friend i dound that command in another website and it is  working but thank you so much ! 
    what about 2 differet name ? 
    Possible ?
    Get-ADComputer -Filter {Name -like "TLV*,ISR*"}
    My Website:www.Pelegit.co.il Mcitp /Mcsa 2012
    You would need separate statements like
    -Filter {(Name -Like "TLV*") -and (Name -Like "ISR*")}
    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.
    Don't Retire Technet

  • Simply get computer name with serial number

    Hi All,
    I use the script below to get serial number, but I have no idea how to get the computer name in the meantime.
    Pls point me.
    $File = [System.IO.File]::OpenText("d:\111.txt")
     while($Machine = $GuyFile.ReadLine())
    {Get-WmiObject -computername $Machine win32_SystemEnclosure }
    $GuyFile.Close()

    Hello Andrejs,
    Try this, May be the formatting would be little off.. but you shud get the results.
    function Get-ServerInfo {
    PROCESS {
    $computername = $_
    $data = Get-WmiObject -class Win32_logicalDisk -ComputerName localhost | Select PSComputerName, DeviceID,@{n='Size(GB)';e={$_.size / 1gb -as [int]}},@{n='Free(GB)';e={$_.Freespace / 1gb -as [int]}}
    $bios = Get-WMIObject -Class Win32_BIOS
    $value = $data + $bios
    $value | select PSComputerName, DeviceID,SerialNumber,'Size(GB)','Free(GB)'
    Get-Content c:\servers.txt | Get-ServerInfo | Format-Table -auto
    It generates, computername, Drives , Size of drives, free space (in GB), serial number
    put your server list in c:\servers.txt
    Regards,
    Venu
    Venu

  • API for getting iView name, type, tCode

    Hi
    I am trying to figure out if there is a way in my program to get iView properties: the iView type (e.g. transaction, Web Dynpro, etc), then if it's a transaction iView to get the tCode for that iView.
    I have seen document that tells me I can get the list of iViews in a given PCD location, and I think you can get the properties I mentioned above as such:
    // id is the full path of the iView
    public void getProperties(IPortalComponentRequest request , String id) throws Exception{
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, IPcdContext.PCD_INITIAL_CONTEXT_FACTORY);
    env.put(Context.SECURITY_PRINCIPAL, request.getUser());
    env.put(Constants.REQUESTED_ASPECT, PcmConstants.ASPECT_SEMANTICS);
    InitialContext iCtx = null;
    try {
    iCtx = new InitialContext(env);
    IiView result = (IiView) iCtx.lookup(id);
    result.getAttribute("????");
    result.getAttribute("????");
    } catch (Exception e) {
    throw new Exception (e);
    Am I in the right direction?
    I don't know what are the names of those attributes I need? - I cannot find them in any Java docs or forum?
    I also looked at com.sap.portal.pcm.attributes.IAttriView but that does not appear to have the suitable attributes that I am looking for?
    Please help.
    Kind regards,
    Sharath

    Hi
    Check theses links
    http://help.sap.com/erp2005_ehp_03/helpdata/EN/44/bfb2a470033f45e10000000a114a6b/frameset.htm
    https://help.sap.com/javadocs/NW04S/current/index.html
    Hope this helps.
    Cheers-
    Pramod
    reward points if helpful.

  • Integration API method to get display name

    Is there a method in Integration API to get display name of columns.
    I want a method like getDisplayName(string fieldName) returns the name displayed on Primavera UI.

    Hi Onkar,
    not sure if you already testet it like that, but as far as I know the full username of an AD user is displayed just the way it is, for an enterprise user.
    Have you checked, if the full name is filled with AD information?
    If not, you might check your settings in the CMC -> "Authentication" -> "Windows AD" -> "Import Full Name and Email Address"
    I can not check it with our test system, cause our user names are identical to our full names.
    But it might give you a hint!
    Regards
    Jan
    Edited by: Jan Fröhlich on Jul 23, 2009 1:00 PM

  • LOGICAL SYSTEM NAME OR COMPUTER NAME

    Dear Experts,
    How can we get computer name of the user in SAP,agaisnt bsuiness transactions for outbound deliveries and finance documents.
    Best rgds
    Mani

    Hi,
    enter SM04.
    regards

  • How to get a computer name in teststand step ?

    how to get a computer name in teststand step ?

    Hi,
    Use an ActiveX Automation Adapter with the following settings,
    ActiveX Reference : RunState.Engine
    Automation Server: TestStand API (depends on your version)
    Object Class: Engine (IEngine)
    Action: Get Property
    Property: ComputerName
    Then set your Parameters: to pickup the String ComputerName.
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • How to get the computer name in a text box automatically?

    Hi,
    I am using flash cs4 (AS3). How can I get the computer name/username in a text box created for grabbing Username from the computer and show it in the username textbox automatically?
    Thanks.

    You can't running a SWF on a webpage. Can you imagine if a SWF had access to that OS-level information? It breaches everything Flash, browsers and the web stands for, which is "not being an application", therefore it has absolutely no access to your computer. Especially information like your username.
    If you're running a flash projector, that's different. Not that a projector can do that either, but projectors are applications and can be extended by things like MDM Zinc and ScreenTime mProjector. Going that route opens up the constraints on Flash Projectors and lets you tap into things like .dlls. Only via that route are you going to be able to get at such a low level item like the current logged on user.

  • Getting the user name and computer name

    I've been trying to find out how to do this, but can't seem to get it.
    I have an AIR application that needs to get the user's login name, and computer name for verification.  I can't find anywhere to do this.  Is AIR able to get this information? Is there work arounds if there isn't?
    It won't ever be a web app, just an AIR app.

    What I did in Air 2 to accomplish that is the following:
                   public function getHostName():void {
                        if(NativeProcess.isSupported) {
                             var OS:String = Capabilities.os.toLocaleLowerCase();
                             var file:File;
                             if (OS.indexOf('win') > -1) {
                                  //Executable in windows
                                  file = new File('C:\\Windows\\System32\\hostname.exe');
                             } else if (OS.indexOf('mac') > -1 ) {
                                  //Executable in mac
                             } else if (OS.indexOf('linux')) {
                                  //Executable in linux
                             var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
                             nativeProcessStartupInfo.executable = file;
                             var process:NativeProcess = new NativeProcess();
                                  process.addEventListener(NativeProcessExitEvent.EXIT, onExitError);
                                  process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutput);
                                  process.start(nativeProcessStartupInfo);
                                  process.closeInput();
                   import utls.StringHelper;
                   public function onOutput(event:ProgressEvent):void {
                        var strHelper:StringHelper = new StringHelper();
                        var output:String = event.target.standardOutput.readUTFBytes(event.target.standardOutput.bytesAvailable);
                             output = strHelper.trimBack(output, "\n");
                             output = strHelper.trimBack(output, "\r");
                        trace('"'+output+'"');
    The package that I used is from the manual:
    package utls
         public class StringHelper
              public function StringHelper()
              public function replace(str:String, oldSubStr:String, newSubStr:String):String {
                   return str.split(oldSubStr).join(newSubStr);
              public function trim(str:String, char:String):String {
                   return trimBack(trimFront(str, char), char);
              public function trimFront(str:String, char:String):String {
                   char = stringToCharacter(char);
                   if (str.charAt(0) == char) {
                        str = trimFront(str.substring(1), char);
                   return str;
              public function trimBack(str:String, char:String):String {
                   char = stringToCharacter(char);
                   if (str.charAt(str.length - 1) == char) {
                        str = trimBack(str.substring(0, str.length - 1), char);
                   return str;
              public function stringToCharacter(str:String):String {
                   if (str.length == 1) {
                        return str;
                   return str.slice(0, 1);
    And sorry for the miss topic I just realized that it is on flex topic, but I post it either way it may be useful for anyone

  • How to get client computer name in Developer 9i

    Hi ..
    I m using developer 9i from several days.But i need to get the client computer name.But i heard that i need to use GetClientInfo java bean to get that.How to use GetClientInfo.What is the procedure to use that?What code i should use?In Sample code in this site..there was a example.But in that example there is nothing clear.What to do and what code should i use?
    Sharif

    This shouldn't be any problems if you'd successfully installed the Forms Demos. Anyhow, another way is to use WebUtil which I'd prefer. There's tons of other interesting and useful functions in WebUtil.
    Also, I'd really, really think about using Forms 10g instead of 9i.
    Regards,
    Martin Malmstrom

  • How to get cleint computer name in Flex

    I am using SBI(Spring BlazeDS Integration) for my project.I need to send the computer name from flex client.I try it with
    Using the Capabilities classFollowing Link Also didnt help for me.....
    http://livedocs.adobe.com/flex/3/html/index.html?content=18_Client_System_Environment_1.ht ml
    If Any body please help me...
    And Following is answer for http://forums.adobe.com/thread/630928?tstart=0
    <mx:DataGridColumn headerText="Allocated Amt"
    editorDataField="text" dataField="allocatedAmt"
    itemRenderer="mx.controls.TextInput" editable="true"/>
    Just replace TextInput--->Your decide controll

    Hi,
    Yes its true,
    But then, brother again I am calling to server,isn't it? Then server will return me his computer name. But I want to get a client computer name.
    hostname is Server Computer name. Isn't it?
    try {
        InetAddress addr = InetAddress.getLocalHost();
        byte[] ipAddr = addr.getAddress();    // Get IP Address
        String hostname = addr.getHostName();   // Get hostname
    } catch (UnknownHostException e) {
    Any way thnx brother....Any ideas from you???
    Happy Codding.......

  • Computer name keeps getting (2) appended to it.

    I've searched high and low and can't seem to figure out why my iMac thinks the computer name is already being used on the network.
    I can see in the sharing preference pane that the original name is what is indicated with this copy:
    Computers on your local network can access your computer at: XXXXX.local
    However, the name in the field above it has XXXXX (2) and each time I try to get rid of the (2) I get the message:
    The name of your computer “XXXXX” is already in use on this network. The name has been changed to “XXXXX (2)”
    I can change the name using the EDIT button to anything else I want, and it doesn't add the (2). But once I change it back to my desired computer name, I get the same message that it's already being used.
    I've tried turning off all of my sharing services but that still doesn't seem to allow the name to be used.
    Any idea what other process is running that can be using the name? How do I figure out where the conflict is occurring?

    Thanks for the suggestion, Alberto. I turned all networking off and was able to make the change successfully. However, once I turned networking back on again, the same message popped up:
    The name of your computer “XXXXX” is already in use on this network. The name has been changed to “XXXXX (2)”
    In the Sharing Preference Pane, I verified that it appears to still be using the correct .local name:
    Computers on your local network can access your computer at: XXXXX.local
    But the Computer Name in the field above the message switched to XXXXX (2) again.

  • Time Capsule error 22 - My time capsule was working fine and didn't notice anything wrong with it until it stopped backing up about two weeks ago. I never changed anything like computer names or the Airport settings. All I get is the following: The backup

    Time Capsule error 22 - My time capsule was working fine and didn't notice anything wrong with it until it stopped backing up about two weeks ago. I never changed anything like computer names or the Airport settings. All I get is the following:
    The backup disk image "/Volumes/Data/Linda's Computer 1.sparsebundle" could not be created (error 22).
    I tried resetting the Time Capsule and connecting with an ethernet cable, although the Ariport Utility says everything is working fine through WiFi.

    If the light will not turn on the TC is dead. No matter that the hard disk is running.. it should only run at start up or when it is accessed not constantly.. that means the board in the TC has failed. Apple do not repair them.. They will replace it under warranty or applecare.
    If you have gone over the 12month warranty it will still be covered if you have applecare on any computer or an Apple TV. In fact the cost of the apple TV plus apple care is still cheaper than buying a new TC.. so it is a route some people are taking.. certainly depends.. in some places like Europe or Australia now, there is a recognition that statutory warranty must be longer on a product that is premium to the market. 12months is not good enough. Apple will sometimes listen.
    They might be fixable but I do not know how.

  • Report that gets full name from the users id in the computer name

    I don't even know if this is possible, but I am finding that quite often of late I am needing to get the users full name from the computer name.
    We have a standard where a computer name is in this format XXXXXXXUSERID.
    Is there a way to get the Full name from the USERID that is in the computername (not last logged on user).
    I am fairly sure that I might be able to work it out in SQLSMS but I really need it on the web reports form SCCM.
    If anyone has any ideas please let me know.

    Thanks, I want to add it to most my reports but this is the main one that I am using right now due to an audit. 
    SELECT DISTINCT
    CS.Name0 AS 'Computer Name', CS.Domain0 AS 'Domain', CS.UserName0 AS 'User', BIOS.SerialNumber0 AS 'Bios serial',
    SE.SerialNumber0 AS 'System Enclosure serial', CS.Manufacturer0 AS 'Manufacturer', CS.Model0 AS 'model', OS.Caption0 AS 'OS',
    RAA.SMS_Assigned_Sites0 AS 'Site', RAM.TotalPhysicalMemory0 AS 'Total Memory', SUM(ISNULL(LDisk.Size0, '0')) AS 'Hardrive Size',
    SUM(ISNULL(LDisk.FreeSpace0, '0')) AS 'Free Space', CPU.Name0 AS [CPU Name]
    FROM dbo.v_GS_COMPUTER_SYSTEM AS CS RIGHT OUTER JOIN
    dbo.v_GS_PC_BIOS AS BIOS ON BIOS.ResourceID = CS.ResourceID RIGHT OUTER JOIN
    dbo.v_GS_SYSTEM AS SYS ON SYS.ResourceID = CS.ResourceID RIGHT OUTER JOIN
    dbo.v_GS_OPERATING_SYSTEM AS OS ON OS.ResourceID = CS.ResourceID RIGHT OUTER JOIN
    dbo.v_RA_System_SMSAssignedSites AS RAA ON RAA.ResourceID = CS.ResourceID RIGHT OUTER JOIN
    dbo.v_GS_X86_PC_MEMORY AS RAM ON RAM.ResourceID = CS.ResourceID RIGHT OUTER JOIN
    dbo.v_GS_LOGICAL_DISK AS LDisk ON LDisk.ResourceID = CS.ResourceID RIGHT OUTER JOIN
    dbo.v_GS_PROCESSOR AS CPU ON CPU.ResourceID = CS.ResourceID RIGHT OUTER JOIN
    dbo.v_GS_SYSTEM_ENCLOSURE AS SE ON SE.ResourceID = CS.ResourceID
    WHERE (LDisk.DriveType0 = 3)
    GROUP BY CS.Name0, CS.Domain0, CS.UserName0, BIOS.SerialNumber0, SE.SerialNumber0, CS.Manufacturer0, CS.Model0, OS.Caption0, RAA.SMS_Assigned_Sites0,
    RAM.TotalPhysicalMemory0, CPU.Name0
    What I really want to do is add another column called owner that just has the UID in it, I will then try to pull the users full name into another column.. hopefully I am not biting off more then I can chew with this but i have thousands of records and i
    will be forced to export to excel or something then look up all the names if I can't do this...

Maybe you are looking for

  • Data recovery - HELP!

    Hi there I have done the stupidest thing EVER! I back up my entire MacBook on an external hard drive - so far, so sensible. Only I've updated what I've backed up by replacing folders with newer versions and I've only just realised. I've lost four yea

  • Sale order status

    Hi Guru, Please help me take the SO status from table? HieuLM

  • How to use the function who returns an array?

    how to use getAllT in pls/sql or in java? ---------------------------------------------------> create or replace package honghai as      type TType is varray(25) of number; /*it can be like : type TType is table of number;      function getCountT ret

  • Number of rows in Record Working Time.

    Hello Guru's, IN ESS- Record Working Time - the number of rows visible are set to 8 in the Web Dynpro Java Code. I had a look at the Note: Note 957741 - Few lines in the data entry grid of the timesheet webdynpro The question I had is to have more th

  • Migrate sql server dump file to Oracle database on a network

    I have a sql server dump file provided to me by DBA's. I have to migrate this dump file to Oracle database on a network. Please suggest me the steps to do this.