• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

servername

 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i am looking for a simple way to display the name of the server on my server gui. I know this is unnesseccary for the assignment, but it will help me.
Another question, are you allowed to use the System.getProperty methods to retrieve the user directory.
thanks,
friso
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi f,

i am looking for a simple way to display the name of the server on my server gui. I know this is unnesseccary for the assignment, but it will help me.


On the server GUI's JFrame just call super(title) (assuming you subclass JFrame) in the GUI constructor or call setTitle(title). Of course the title will have to be initialized to the server name. Or you could dedicate a JLabel somewhere on the GUI to display it.

Another question, are you allowed to use the System.getProperty methods to retrieve the user directory.


Of course. Feel free to use any tool available to you in the J2SE arsenal.
Hope this helps,
Michael Morris
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


On the server GUI's JFrame just call super(title) (assuming you subclass JFrame) in the GUI constructor or call setTitle(title). Of course the title will have to be initialized to the server name


I did the same, -- in networked mode, my client JFrame title bar showed "Fly High -- Connected to db.db on serverName:1099". In local mode, the title bar is "Fly High -- Connected to c:\userdir\db.db".
Eugene.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I did the same, -- in networked mode, my client JFrame title bar showed "Fly High -- Connected to db.db on serverName:1099". In local mode, the title bar is "Fly High -- Connected to c:\userdir\db.db".


That's pretty cool.
Mark
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry guys,
you did indeed answer the question i asked. However i phrased it totally wrong. I know how to display something on a label or on a frame.
But.. my question was supposed to be
how can i extract the servername on the server ?
what java commands do i need to use ?
regards,friso
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friso,
Sorry for the confusion. What exactly do you mean by server name? Do you mean DNS or IP name? Do you mean host name? If you can clarify that, we'll see what we can come up with.
Michael Morris
 
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think he wants the name of the machine that the server is started on so that when you start the server at the command line, it will know what to call itself.
Ex: java -jar server.jar
When the GUI pops up for the server it says "I am remote.server.com" blah...
I dont know but I would guess if anything it would be in a System.getProperty()
 
town drunk
( and author)
Posts: 4118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IMO, you're fine to just say "local connection" or "remote connection". My advice is to not waste your time on this: there are probably other parts of the test that would be a better time investment.
Best regards,
M, author
The Sun Certified Java Developer Exam with J2SE 1.4
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, if he wants the local host name then he needs to get it thus:

On my workstation it returns MOMNT/192.168.0.101. I am behind a firewall with a lan IP as indicated and host name MOMNT.
Hope this helps,
Michael Morris
[ August 06, 2002: Message edited by: Michael Morris ]
 
friso dejonge
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Michael, this works fine
you code line would have to be extended with :
host = InetAddress.getLocalHost().getHostName();
but this is exactly what i wanted.
(nate, thanks as well for the further explanation)
reply
    Bookmark Topic Watch Topic
  • New Topic