Username Password

Lost Password
View Thread
Explore Your Brain » Pemrograman » Java
Error Getting HostName
Username
Password
Register FAQ Members List Today's Posts Search

Print Thread

25-11-2013 05:38 AM Error Getting HostName | Edited by bristimjet 01-12-2013 04:27 AM
User Avatar

bristimjet
Murid Akademi I


Posts: 1
Joined: 25.11.13
I want to print the local host name, but it always prints null .. how can I get host name ?
Java Code
String hostname = System.getenv("HOSTNAME"Wink;
System.err.println("Hostname = " + hostname);
______________________________
Online fax
 
Offline
26-11-2013 03:20 AM RE: Error Getting HostName
User Avatar

EVA-00
HackAge


Posts: 2770
Joined: 21.05.08
Location: Wallahu a'lam
Age: 38
Try this,

package testing;
import java.net.*;
public class Test
{
public static void main(String[] args) throws UnknownHostException
{
System.out.println(InetAddress.getLocalHost().getHostName());
}

Nabi Muhammad SAW bersabda :ā€¯ Barangsiapa Yang Mengamalkan Ilmu Yang Ia Ketahui Maka Allah Akan Memberikan Kepadanya Ilmu Yang Belum Ia Ketahuiā€¯ (HR. Imam Ahmad).

..::shn6 u!vJq Jnoh 3Joldx3 d33>I::..
 
Offline
Jump to Forum:
Forum powered by fusionBoard
Share this Thread
URL:
BBcode:
HTML:
Similar Threads
Thread Forum Replies Last Post
Dasar Pemrograman Java - Chapter01 x Requirement, Compile, Error & Run Java 3 01-04-2012 03:33
[Ask] flashdisk error Out Of Topic 3 26-01-2011 12:29
6 Arti Pesan Error Ketika Akses Internet Info Security 17 19-02-2010 04:39
download error Kritik & Saran 2 21-01-2010 10:49
code error zynga poker...?? Out Of Topic Programing 3 15-01-2010 22:31
Copyright © 2007-2016