This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes servername Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "servername" Watch "servername" New topic
Author

servername

friso dejonge
Ranch Hand

Joined: Jul 11, 2002
Posts: 162
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


swimming certificate (A & B), shoelaces diploma, and some useless java ones.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
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


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

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.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
friso jonge
Ranch Hand

Joined: Aug 06, 2002
Posts: 41
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

Joined: Jan 30, 2002
Posts: 3451
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
Nate Johnson
Ranch Hand

Joined: May 13, 2002
Posts: 301
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()


scwcd, scjd, scjp<br /><a href="http://natejohnson.us" target="_blank" rel="nofollow">http://natejohnson.us</a><br /><a href="http://rice.kuali.org" target="_blank" rel="nofollow">http://rice.kuali.org</a>
Max Habibi
town drunk
( and author)
Sheriff

Joined: Jun 27, 2002
Posts: 4118
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


Java Regular Expressions
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
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

Joined: Jul 11, 2002
Posts: 162
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)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servername
 
Similar Threads
RMI from start to finish
James Mail Server
Accept compresed requests in tomcat
Need help in build applications using ant : getting exception
Http Post