Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Loading images and other files from server

Posted on 2005-04-01
11
Medium Priority
?
157 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
  • 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
Industry Leaders: 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

Industry Leaders: 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!

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

578 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