Easy to Learn Java: Programming Articles, Examples and Tips

Start with Java in a few days with Java Lessons or Lectures

Home

Code Examples

Java Tools

More Java Tools!

Java Forum

All Java Tips

Books

Submit News
Search the site here...
Search...
 
Search the JavaFAQ.nu
1000 Java Tips ebook

1000 Java Tips - Click here for the high resolution copy!1000 Java Tips - Click here for the high resolution copy!

Java Screensaver, take it here

Free "1000 Java Tips" eBook is here! It is huge collection of big and small Java programming articles and tips. Please take your copy here.

Take your copy of free "Java Technology Screensaver"!.

Java Newsletters Archive: 17

JavaFAQ Home » Java Newsletters Go to all tips in Java Newsletters


Bookmark and Share ***********************************************
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ *
* > The Java FAQ Daily Tips, weekly publication < *
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ *
*
* Issue No: 17 27 December 2000
* http://www.javafaq.nu/java
*
*
* Please recommend our FREE "100 Java Tips" book and us to your
* friends and colleagues!
* http://javafaq.nu/java/advert/our_book.shtml
***********************************************

Table of Contents

1. I don't know anything about security... Part 2.
2. I guess what I'm asking is "Is java.util.Hashtable
thread safe?"
3. Is there any way to run code after the VM has been
instructed to exit?
4. Why would anyone use AWT and not Swing today?
5. I'm working on a java project and looking for a better
API that can generate PDF, work with Excel, Word documents...
6. Where can I find Java --> Native code compilers?
7. I have a directory having class files arranged in package
hierarcy. How can I make the executable of this whole directory?
***********************************************

Hello dear friends!

Happy New Year!
If you have your good tips please send us and we will add it to our
free book! One sunny day when your friends will load the new version of
our book they will find your name there also!

I hope you will have enough time to check Zapper - that make life much
easier and offers a new, more efficient way to get the information
you need from the Web.
It takes you from wherever you are on your desktop to exactly
what you're looking for on the Web - in just one click of your mouse!


Tip 1 Q: I need to read C: est.doc for example and store it
somewhere for my future use. I don't know anything about security.
Part 2, Part 1 was published last week.

Answer :
I think they want you to go out and buy a cert from Verisign or
Thawte, etc. You can also generate your own signing certificate
through openSSL, or some other package, but, if you do, you'll
need to have them import it into their database as a trusted signer.
This can be done with a simple Perl script which sends the
certificate with a header of:
"Content-Type: application/x-x509-ca-cert"
You must also add some code to your applet to use the Netscape
way of signing. You can download the file 'capsapi_classes.zip'
from Netscape. This file contains the Netscape Capabilities API.
Basically, all you need to do is import the package and enable
privileges as you need them. It is important to enable privileges
in the same method (ie. same frame stack)
in which you are going to use them. You cannot just enable all
the privileges you need in the init method of your applet. The
code looks something like this:

import netscape.security.*;
public void MyMethod() {

try {
PrivilegeManager.enablePrivilege("UniversalFileRead");
FileInputStream fis = new FileInputStream("myfile");
} catch (Exception e) {
System.out.println(e);
}
} // end MyMethod

You'll need to add 'capsapi_classes.zip' to the archive attribute
of your applet tag. I also believe it is possible to grant
privileges to a codebase in Netscape without signing. This is
done by editing the 'prefs.js' file on the client. Obviously,
this is not possible on the internet, but, for an intranet
environment, this could be a solution. Anyway, when an applet
tries to enable a privilege, the Netscape browser will pop up a
window asking the user if they wish to grant the privilege. This
decision can be persistent.
The user can manage the privileges they have granted by clicking
on the padlock icon in the bottom left corner of their browser
window, and selecting the "Java/JavaScript" section.

If your users may be using Microsoft IE as well as Netscape,
you'll have to learn the Microsoft security API. I haven't done
this yet, but I believe it is possible to code an applet so that
it will work in either browser.
Another alternative is to code different versions of the applet,
and build the page containing the applet dynamically, based on
the "User-Agent". I have found that it is possible in IE to grant
universal privileges to an applet, even if it is not signed, but
I sure wouldn't recommend doing that.



***********************************************

Tip 2 Q: I guess what I'm asking is "Is java.util.Hashtable
thread safe?"

It's been a while since I've used hashtables for anything
significant, but I seem to recall the get() and put()
methods being synchronized.
The JavaDocs don't reflect this. They simply say that the class
Hashtable is synchronized. What can I assume? If several threads
access the hashtable at the same time (assuming they are not
modifying the same entry), the operations will succeed, right?
I guess what I'm asking is "Is java.util.Hashtable thread safe?"

A: That is right! It is recommendable, if you have questions like
these, always look at source for the api, it's freely available.

***********************************************

Tip 3 Q: Is there any way to run code after the VM has been
instructed to exit?

A: In 1.3, you can use Runtime.addShutdownHook(Thread hook)


***********************************************

Tip 4 Q: Why would anyone use AWT and not Swing today?

A: There are several handheld devices that do not have a lot of
memory or CPU power available, AWT is more suitable for them
(Smaller footprint).


Tip 5 Q: I'm working on a java project and looking for a better
API that can generate PDF, work with Excel, Word documents...
Where can I find it?

Answer: We have a list here:
http://www.javafaq.nu/java/office/index.shtml


***********************************************

Tip 6 Q: Where can I find Java --> Native code compilers?

Answer: We just published a list of Java products that lets you do
Java --> Native code compilation:
http://javafaq.nu/java/staff/staff.shtml


***********************************************

Tip 7 Q: I have a directory having class files arranged in package
hierarcy. How can I make the executable of this whole directory?

Any application available for that in Windows NT environment.

Answer: Make a JAR file out of it and add a manifest file that
indicates which main() method of which class must be called.
Double-clicking this JAR file will run your application.


The Java FAQ Daily Tips is a newsletter that is only sent to those
who have specifically subscribed to it.

Copyright (c) 2000 John Andersson
***********************************************
* *
* You can find our tips on site also! *
* Please recommend us and our FREE "100 Java Tips" book to your *
* friends and colleagues! *
* http://javafaq.nu/java/advert/our_book.shtml *
* *
***********************************************
 Printer Friendly Page  Printer Friendly Page
 Send to a Friend  Send to a Friend

.. Bookmark and Share

Search here again if you need more info!
Custom Search



Home Code Examples Java Forum All Java Tips Books Submit News, Code... Search... Offshore Software Tech Doodling

RSS feed Java FAQ RSS feed Java FAQ News     

    RSS feed Java Forums RSS feed Java Forums

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest 1999-2006 by Java FAQs Daily Tips.

Interactive software released under GNU GPL, Code Credits, Privacy Policy