Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

regd Java  and scripting

Posted on 2002-04-25
10
Medium Priority
?
177 Views
Last Modified: 2010-03-31
Hi

I have a java applet

I have a java object called "Volume" which has certain
attributes like
Name
WWN
Capacity

Now I want to automate the process of creating these
volume objects by reading these properties from some file
say " volume.txt"

For example If have a right click menu option
"import" I could read the properties from "Volume.txt"
and create a new volume object

Also the user could change the values in this file
that is user could edit this file


If I use a simple .txt file for this then I would need
to parse this file which gets complicated

I have looked into creating PDF files from a java application.
But I am not sure there is an easy way to parse these
PDF files or edit them

What could be a good way to do this?

How would I parse the txt files?
Is there any tool available to do this

Please share if there is any other approach

like using a simple scripting language

Thanks













0
Comment
Question by:sanjay_thakur
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 7

Expert Comment

by:tomboshell
ID: 6970635
If you use the properties object and store the data with matching pairs you could do it quick and easy.  It works like an ini data that most everybody is familar with.  It would only require that your data is in a format like "key=value" then you would make the call to load the data, and could use each set like a hashmap.  

I think the properties object would be best for you.  You are already calling them properties.  Take a look in the java.util package for the class.  The Javadoc gives it straightforward on how to implement it.  

Tom
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 6970958
I agree with the above. You'll have to store the file containing the properties in the applet's codebase or you won't be allowed to write to it (or read from it for that matter).
0
 
LVL 1

Expert Comment

by:iartmirko
ID: 6971062
Yes, it's java.util.Properties and then use the load() Method...but this won't work for applets...

I am not really sure why you want to store thes properties in a file...take a DB for saving user input on the server and use these entries for generating your volume objects. You could even use EJBs for the volume objects with CMP...Your applets could connect to them using RMI-IIOP and the Volumes home object would like like a local instance...


For PDF manipulation/generation you can use XML and XSL-FO...it works fine, used it in my last project. For an implementation of XSL-FO and a free processor see http://xml.apache.org/fop/index.html

Have fun!

Mirko
0
Independent Software Vendors: 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!

 
LVL 4

Author Comment

by:sanjay_thakur
ID: 6971882
Lets say there is some file on the clients harddrive or A: or anywhere called "Volume.txt"

In the Applet there is a button called "export from"
When the user clicks on this button ,a file chooser is loaded and this file "Volume.txt" is selected

The Applet has to parse this file and find if the values needed to create a new volume object exist.

If the Applet could read and parse this file and find enough information to create a new volume object
It will ; else return an error message


Now the problem is that this "volume.txt" could have any thing.

Even if this file was "Volume.properties" with something like

name:volume
capacity:100 gb

There are problems
This "Volume.properties" will not essentially be in the applets codebase

If this file is not in the applets codebase can the applet still access this file and read from it?

I doubt.

Thus I need to stick with some .txt or .xml file
and then the parsing gets involved


for mirko
I will look into and see if I could use xml

Thanks all of you











0
 
LVL 4

Author Comment

by:sanjay_thakur
ID: 6984837
Hi all

Is it possible to read the Properties file
if it is not in the Applet's codebase

For example
I create a new Volume Object  with properties
"name==Volume "
"wwn ==192.168.."

now I want to export these values in a file "MyVolume.properties"

now The user can create multiple new volumes
by saying "export" and exporting "MyVolume.properties"

The application will read from "MyVolume.properties"
and create new volume object

Please let me know if this is a possible ?

Thanks all



0
 
LVL 86

Expert Comment

by:CEHJ
ID: 6984842
>>Is it possible to read the Properties file
if it is not in the Applet's codebase

Yes, but you'll have to sign it. Check out this excellent article:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1215-security.html
0
 
LVL 7

Expert Comment

by:tomboshell
ID: 6985327
Yes, the further capabilities would go outside of the applets sandbox.  Applets are designed by default to work ONLY within the web-browser once deployed.  Here is some further information to accompany the above artice: http://java.sun.com/sfaq/

tom
0
 
LVL 7

Accepted Solution

by:
tomboshell earned 200 total points
ID: 6985333
oh ya, here it the link to the java tutorial on the security manager to continue the further accompanying information.  
http://java.sun.com/docs/books/tutorial/essential/system/securityIntro.html
0
 
LVL 4

Author Comment

by:sanjay_thakur
ID: 6986808
Hi all,

I will try signing the applet and
reading/writing from the properties file


Please have patience.
I will try this and let you know if I am stuck somewhere

Is there is any other workaround to do the same
without signing the applet?

Just a thought!

Thanks all
0
 
LVL 4

Author Comment

by:sanjay_thakur
ID: 7021933
I have not yet tried signing the applet but I guess
that is not a part of this question

Thanks for all the help
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

885 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