?
Solved

Loading images and other files from server

Posted on 2005-04-01
11
Medium Priority
?
156 Views
Last Modified: 2010-03-31
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
0
Comment
Question by:accarvajal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 15

Expert Comment

by:aozarov
ID: 13685728
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
 

Author Comment

by:accarvajal
ID: 13689207
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
 
LVL 15

Expert Comment

by:aozarov
ID: 13689317
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:accarvajal
ID: 13689538
I forgot something. Client machine is in the same local network as server machine
0
 

Author Comment

by:accarvajal
ID: 13689541
My application is not web oriented, is swing - standalone (Frames and Dialogs)
0
 
LVL 15

Expert Comment

by:aozarov
ID: 13689593
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
 

Author Comment

by:accarvajal
ID: 13690139
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
 
LVL 15

Expert Comment

by:aozarov
ID: 13690405
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
 

Author Comment

by:accarvajal
ID: 13692108
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
 

Author Comment

by:accarvajal
ID: 13692118
I forgot! for HTTP is requiered web server software like tomcat or IIS be set and installed?
0
 
LVL 15

Accepted Solution

by:
aozarov earned 120 total points
ID: 13692309
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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month14 days, 9 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question