- Make jar file of your class files and resources like icons, images etc. using following command:
jar cf JarFileToCreate.jar abc.class def.class ...
For More details on creating Jar files, see create-jar-file-for-java-app - Make jnlp extension text file with following information:
<?xml version="1.0" encoding="UTF-8"?> <jnlp spec="1.0+" codebase="http://localhost/jnlp" href="MyApp.jnlp"> <information> <title>My App Title</title> <vendor>MonishVendor</vendor> </information> <resources> <!-- Application Resources --> <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/> <jar href="TestApp.jar" main="true" /> </resources> <application-desc name="DemoName" main-class="GUI_QPDownloader" width="300" height="300"> </application-desc> <update check="background"/> </jnlp> - That's all. Now run jnlp file from any web-browser to test
Steps for Java Web Start
How to create jar file for the java app you make.
Modifying a Manifest File
You use the m command-line option to add custom information to the manifest during creation of a JAR file. This section describes the m option. The Jar tool automatically puts a default manifest with the pathname META-INF/MANIFEST.MF into any JAR file you create. You can enable special JAR file functionality, such as package sealing, by modifying the default manifest. Typically, modifying the default manifest involves adding special-purpose headers to the manifest that allow the JAR file to perform a particular desired function.
To modify the manifest, you must first prepare a text file containing the information you wish to add to the manifest. You then use the Jar tool's m option to add the information in your file to the manifest.
Warning: The text file from which you are creating the manifest must end with a new line or carriage return. The last line will not be parsed properly if it does not end with a new line or carriage return.
The basic command has this format:
To modify the manifest, you must first prepare a text file containing the information you wish to add to the manifest. You then use the Jar tool's m option to add the information in your file to the manifest.
Warning: The text file from which you are creating the manifest must end with a new line or carriage return. The last line will not be parsed properly if it does not end with a new line or carriage return.
jar cfm jar-file manifest-addition input-file(s)
Effective C++ Ed. 3rd: Item 43: Know how to access names in templatized base classes
In derived class templates, refer to names in base class templates via
prev | next
- a "this->" prefix
- using declarations or
- an explicit base class qualification like:
Base::func()
prev | next
Effective C++ Ed. 3rd: Item 42. Understand the two meanings of typename
What's the difference between the following two declarations:
But use typename to identify nested dependent type names, except in base class lists or as a base class identifier in a member initialization list.
prev | next
template<class T> class Widget; // uses "class" template<typename T> class Widget; // uses "typename"When declaring template parameters, class and typename are interchangeable.
But use typename to identify nested dependent type names, except in base class lists or as a base class identifier in a member initialization list.
prev | next
Effective C++ Ed. 3rd: Item 40. Use multiple inheritance juriciously
With multiple inheritance (MI), you may have a class hierarchy with more than one path between a base class and a derived class. For example:
class basic_ios { ... };
class basic_istream: public basic_ios { ... };
class basic_ostream: public basic_ios { ... };
class basic_iostream: public basic_istream, public basic_ostream
{ ... };To restrict inclusion of members of class basic_istream twice into class basic_iostream, use virtual inheritance. Declare the above classes as:
class basic_ios { ... };
class basic_istream: virtual public basic_ios { ... };
class basic_ostream: virtual public basic_ios { ... };
class basic_iostream: public basic_istream, public basic_ostream
{ ... };But try to avoid virtual inheritance because:- objects created using virtual inheritance are generally larger.
- Access to data members in virtual base classes is also slower than those in non-virtual base classes.
Cheers
Effective C++ Ed. 3rd: Item 39. Use private inheritance judiciously
A class "is-implemented-in-terms-of" might be achieved by:
cheers
- composition (see prev. item for detail)
- private inheritance.
Now, which to use when? Former should be used whenever possible. Private inheritance would be handy when you need to redefine a virtual member function or need to access to protected base class members.
Beside the 2 alternatives mentioned above,
prev | next- we may have a design something like:
class Widget {
private:
class WidgetTimer: public Timer {
public:
virtual void onTick() const;
...
};
WidgetTimer timer;
...
};
In the third alternative's example, we need to redefine onTick() of class Timer.This design is appreciated over private inheritance because 1.the derived classes would not be able to refine onTick(). 2. In case of private inheritance, Widget get compilation dependencies on the definition of class Timer which would force us to #include timer.h Whereas in alternative 3, By defining WidgetTimer class out of the Widget class and placing a pointer to WidgetTimer would require just declaration of WidgetTimer class at the minimum.cheers
Effective C++ Ed. 3rd: Item 38. Model "has-a" or "is-implemented-in-terms-of" through composition
Composition is the relationship between types that arises when objects of one type contain objects of another type. Composition means either "has-a"(things related to application domain) or "is-implemented-in-terms-of."(things related to your software's implementation domain like mutexes, buffer, search trees etc.)
prev | next
Cheers
prev | next
Cheers
Effective C++ Ed. 3rd: Item 37. Never redefine a function's inherited default parameter value
Never redefine an inherited default parameter value, because these are statically bound unlike the virtual functions ( the only functions which should be overridding).
The following NVI technique is one of the alternatives if you want to redefine an inherited default parameter value:
Cheers
The following NVI technique is one of the alternatives if you want to redefine an inherited default parameter value:
class Shape {
public:
enum ShapeColor { Red, Green, Blue };
void draw(ShapeColor color = Red) const // now non-virtual
{
doDraw(color); // calls a virtual
}
...
private:
virtual void doDraw(ShapeColor color) const = 0; // the actual work is
}; // done in this func
class Rectangle: public Shape {
public:
...
private:
virtual void doDraw(ShapeColor color) const; // note lack of a
... // default param val.
};
prev | nextCheers
Effective C++ Ed. 3rd: Item 36. Never redefine an inherited non-virtual function
When base class pointer points to a derived class pointer and an inherited non-virtual function which is refined in derived class, the definition present in base class would execute. This happens because non-virtual functions are statically bind. So
Cheers
- Either declare only those functions non-virtual which will remain invariant in derived classes
- Or use virtual functions or it's alternatives at defines here.
Cheers
Subscribe to:
Posts (Atom)