Username Password

Register Here || 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 12:38 PM Error Getting HostName | Edited by bristimjet 01-12-2013 11: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 10:20 AM RE: Error Getting HostName
User Avatar

EVA-00
HackAge


Posts: 2770
Joined: 21.05.08
Location: Wallahu a'lam
Age: 33
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 10:33
[Ask] flashdisk error Out Of Topic 3 26-01-2011 19:29
6 Arti Pesan Error Ketika Akses Internet Info Security 17 19-02-2010 11:39
download error Kritik & Saran 2 21-01-2010 17:49
code error zynga poker...?? Out Of Topic Programing 3 16-01-2010 05:31
Copyright © 2007-2016