| | |
how to take computer name in linux
![]() |
•
•
Join Date: Apr 2007
Posts: 34
Reputation:
Solved Threads: 1
how to take computer name in linux
I had tried this code in Windows Xp, it's Ok. but while i run in linux i got error
"Cannot get computer name java.net.UnknownHostException: comcentos: comcentos"
i'm using Centos 5.
i have edit in file etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=comcentos
thanks all for your help
I had tried this code in Windows Xp, it's Ok. but while i run in linux i got error
"Cannot get computer name java.net.UnknownHostException: comcentos: comcentos"
i'm using Centos 5.
i have edit in file etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=comcentos
Java Syntax (Toggle Plain Text)
package myPackage; import java.io.* ; import java.net.* ; public class ComputerName { public static void main ( String[] args ) { //To get the computer name try { String computerName = InetAddress.getLocalHost( ).getHostName (); System.out.println ( "Computer Name: " + computerName ) ; } catch ( Exception e ) { System.out.println ( " Cannot get computer name " + e ) ; } } }
thanks all for your help
![]() |
Similar Threads
- Linux won't boot (Getting Started and Choosing a Distro)
- Running 2 OS's on the same computer (Windows 95 / 98 / Me)
- How to send sms from computer to mobile phone? (C++)
- What's better? Windows 2000 Server or Linux Server? (Windows Servers and IIS)
- How to connect to a LINUX machine using VB6 (Visual Basic 4 / 5 / 6)
- [Javascript] My browser/computer doesn't like Javascript...? (JavaScript / DHTML / AJAX)
- Cr4nberry: How to Configure Samba on RedHat Linux (*nix Software)
- need to control my computer via my mobile phone (USB Devices and other Peripherals)
Other Threads in the Java Forum
- Previous Thread: Grade 12 Project
- Next Thread: OS Detection Tool Like Nmap
| Thread Tools | Search this Thread |
add android api applet application applications array arrays automation bank binary bluetooth chat class clear client code codesnippet collections component converter database development dice digit eclipse equation error event formatingtextintooltipjava fractal functiontesting game givemetehcodez graphics gui health html hyper ide idea image infinite input int integer j2me java javame javaprojects jni jpanel julia linux list loop looping main map method methods mobile myregfun mysql netbeans newbie nonstatic openjavafx parameter pearl php print problem program programming project recursion repositories scanner scrollbar server set size sms sort sorting spamblocker sql sqlserver state storm string superclass swing swt text-file thread threads tree windows





