I just edited my hosts file on my rooted Samsung Galaxy S, and the changes took effect immediately. Perhaps the problem you're seeing is something to do with ADB?
I did this:
- Using Busybox, copy the hosts file to an editable location with
cp /etc/hosts /mnt/sdcard/hosts.new
;
- Edit
/mnt/sdcard/hosts.new
using the pre-installed text editor, adding the two entries I need. I used IP, then unqualified hostname, then FQDN, eg 192.168.2.81 siva siva.myinventeddomain.org.au
, but other formats should in theory work too;
- In BusyBox again,
su
to root;
/system
is ro by default, so I had to make it rw with mount -o remount,rw /system
;
- To save typing later,
cd /etc
(whereupon the shell prompt showed /system/etc
rather than /etc
, which makes me suspect symlink shenanigans);
- Back up the default hosts file (which contained only
127.0.0.1 localhost
) with mv hosts hosts.old
;
- Install new hosts file with
mv /mnt/sdcard/hosts.new hosts
;
- Execute
sync
(merely because I am paranoid - this shouldn't be necessary);
- Remount
/system
fs ro with mount -o remount,ro /system
;
- Exit BusyBox;
- Fired up web browser (FireFox) and entered
siva
in the combined URL/search field thingy (siva
being one of the two hosts entries I added).
Prior to these changes, step 11 resulted in a stupid Google search for 'siva' or something; immediately after them, I get my LAN httpd vhost's front page, as I expect.
There was well under 10 minutes elapsed between it working and it not working.
The link to Sun's Java doco may or may not be relevant (probably it isn't).
Android doesn't contain a Java VM at all, let alone Sun's one. It runs a different VM called Dalvik - see Wikipedia entry: http://en.wikipedia.org/wiki/Dalvik_%28software%29
The fact that you can program Android phones in a language that looks a lot like Java is beside the point.
adb pull /etc/hosts
, local edit,adb push hosts /etc/hosts
). Looking for similar help on this topic! – Anguilliform