Loading images and other files from server

Hi!,

If I'm running a JavaSwing app on client machine but app is stored on server machine as a application server, I need to read .properties, .xml and images external files located into a servers folders, how can I do this keeping in mind where app is executed, on server machine or client machine


Thanks
accarvajalAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aozarovCommented:
If your swing application needs resources from your application server then you will need to have some service (EJB, Servlet or simillar)
on the application server that can accept requests for those resources and return them back.
The swing application will need to know where the application server is located (ip,port,jndi driver [if jndi is used]) .
In additon to EJB and Servlet there are many other options for holding and sending the resources such as JNDI itself, HTTP server, FTP service, DATABASE and more.
0
accarvajalAuthor Commented:
But How could I do because my application is swing-standalone, and I do like this for loading an image:

Global.m_sLocalizacionRecursos = "c:/aplicaciones/ARP/images/"

myobj.setIconImage(new ImageIcon(Global.m_sLocalizacionRecursos + "App.gif").getImage());
0
aozarovCommented:
One way to do it can look like that:
if your web application can be accessed at (for example)
http://your_web_site/your_app/ and you have an images folder
then you can do:
myobj.setIconImage(new ImageIcon(new URL("http://your_web_site/your_app/images/App.gif")).getImage());
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

accarvajalAuthor Commented:
I forgot something. Client machine is in the same local network as server machine
0
accarvajalAuthor Commented:
My application is not web oriented, is swing - standalone (Frames and Dialogs)
0
aozarovCommented:
That I know, but I thought you said your resources are located
on the server machine. What do you mean by server machine?
Is just a remote machine or is it a machine running something like one of the following: Application server, Web server, Http server, Ftp server, ...
0
accarvajalAuthor Commented:
I'm thinking to install Application on server machine. This server is Windows2000 server or Professional PC, connected to Network (LAN) with client machines on Windows 2000 professional or Windows98 or XP. What I mean, Is I would like to create shortcuts on every client machine that points to exe application on server. But application needs .jpg, .xml and other files be loaded, these files are located on their own folders, are external files. So!, in server machine instruction like this:

Global.m_sLocalizacionRecursos = "c:/aplicaciones/ARP/images/"

myobj.setIconImage(new ImageIcon(Global.m_sLocalizacionRecursos + "App.gif").getImage());

will work and load images and every file well. But on client machine "c:/aplicaciones/ARP/images" doesn't exists. So images couldn't load because application will try to point to this path on every client machine runs app and this path doesn't exists.
0
aozarovCommented:
So, what about settings ftp or http server on the server
machine, put there the images and then each application can do
 
// "ftp://" when using FTP server
URL globalURL = new URL("http://server_ip/images/");
myobj.setIconImage(new ImageIcon(new URL(globalURL , "App.gif")).getImage());

That will work on both the server machine as well as any other
client machine.

Another way is to put them on a shared folder and map that folder in each one of your client. but this solution is more complex to manage (you need to setup the client where in the other case you only setup once ftp/http service on the server).
0
accarvajalAuthor Commented:
First alternative will work on Linux machines?

URL globalURL = new URL("http://server_ip/images/");
myobj.setIconImage(new ImageIcon(new URL(globalURL , "App.gif")).getImage());

What happens if server_ip has dynamic IP?
0
accarvajalAuthor Commented:
I forgot! for HTTP is requiered web server software like tomcat or IIS be set and installed?
0
aozarovCommented:
First option  (using http or ftp server) will work on any
machine (including linux) as long as your server machine has http/ftp server installed (java URL can connect to http/ftp, so your clients are all set).

For http you can use Apache http server (has versions for both windows and linux).
tomcat or IIS (only for windows) can do the as well (though I recommend Apache which is the most common http server).

If you choose FTP then linux has an ftp server already installed
(activated thru inetd or xinetd) for windows you will need to install one. (Again, this is relevant only for the server machine)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.