Everyone has some standard list of programs, which he starts when logs on to his computer. It’s a waste of time to start each program individually; today we are going to learn how to start all your favorite programs with a single click using batch files. Those of you who don’t know what batch files are may check this post to find out what they are.
I usually use Dreamweaver, Mozilla Firefox, and pidgin immediately after I login to my comp. So let us see how to create a batch file to start the above three programs with a single click.
First open note pad and type the following lines
CD “C:\Program Files\Adobe\Adobe Dreamweaver CS3\”
start Dreamweaver.exe
cd “C:\Program Files\Pidgin\”
start Pidgin.exe
cd “C:\Program Files\Mozilla Firefox\”
start firefox.exe
Here cd switches the control to the directory following it and start command is used to start the program in that directory. You can add any number of programs to this list.
Once you have added all your favorite programs to this list, save it a startup.bat or any other name of your choice and double click on that batch file you created just now to start all your favorite programs.
If you have any problems in creating the batch files feel free to drop in a comment here
Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts
Saturday, June 16, 2012
Start all your programs with a single click using batch file
Labels:
adobe adobe,
Batch,
Batch file,
batch programming,
DOS,
Double-click,
how to create a batch file,
mozilla firefox,
Operating Systems,
PC Tips,
Program Files,
Programming,
software,
technology,
X86
Friday, June 15, 2012
J2EE Tutorial-15(Running the Web Client)
To run the Web client, point your browser at the following URL. Replace
You should see the screen shown in Figure 2-2 after entering

Figure 2-2 Converter Web Client
<host> with the name of the host running the J2EE server. If your browser is running on the same host as the J2EE server, you may replace <host>with localhost.http://<host>:8000/converter
You should see the screen shown in Figure 2-2 after entering
100 in the input field and clicking Submit.Figure 2-2 Converter Web Client
J2EE Tutorial-12(Specifying the JNDI Names)
Although the J2EE application client and the Web client access the same enterprise bean, their code refers to the bean's home by different names. The J2EE application client refers to the bean's home as
To map the enterprise bean references in the clients to the JNDI name of the bean, follow these steps.
Figure 2-1 shows what the JNDI Names tab should look like after you've performed the preceding steps.

Figure 2-1 ConverterApp JNDI Names
ejb/SimpleConverter, but the Web client refers to it as ejb/TheConverter. These references are in the parameters of the lookup calls. In order for the lookup method to retrieve the home object, you must map the references in the code to the enterprise bean's JNDI name. Although this mapping adds a level of indirection, it decouples the clients from the beans, making it easier to assemble applications from J2EE components.To map the enterprise bean references in the clients to the JNDI name of the bean, follow these steps.
- In the tree, select
ConverterApp. - Select the JNDI Names tab.
- To specify a JNDI name for the bean, in the Application table locate the ConverterEJB component and enter
MyConverterin the JNDI Name column. - To map the references, in the References table enter
MyConverterin the JNDI Name for each row.
Figure 2-1 shows what the JNDI Names tab should look like after you've performed the preceding steps.
Figure 2-1 ConverterApp JNDI Names
Labels:
Application programming interface,
Application server,
Bean,
ConverterApp,
enterprise bean,
enterprise-it,
indirection,
J2EE,
j2ee components,
java,
Java Naming and Directory Interface,
Java Platform Enterprise Edition,
jndi,
Programming,
Technology,
web client
J2EE Tutorial-10(Creating the J2EE Application Client)
A J2EE application client is a program written in the Java programming language. At runtime, the client program executes in a different virtual machine than the J2EE server.
The J2EE application client in this example requires two different JAR files. The first JAR file is for the J2EE component of the client. This JAR file contains the client's deployment descriptor and its class files. When you run the New Application Client wizard, the
The second JAR file contains stub classes that are required by the client program at runtime. These stub classes enable the client to access the enterprise beans that are running in the J2EE server. Because this second JAR file is not covered by the J2EE Specification, it is implementation specific, intended only for the J2EE SDK.
The J2EE application client source code is in
The
The
To create the bean instance, the client invokes the
Calling a business method is easy--you simply invoke the method on the
The full source code for the
The application client files are compiled at the same time as the enterprise bean files, as described in Compiling the Source Files.
To package an application client component, you run the New Application Client wizard of the
After the packaging process you can view the deployment descriptor by selecting Tools
Descriptor Viewer.
To start the New Application Client wizard, select File
New
Application Client. The wizard displays the following dialog boxes.
When it invokes the
You specify this reference as follows.
The J2EE application client in this example requires two different JAR files. The first JAR file is for the J2EE component of the client. This JAR file contains the client's deployment descriptor and its class files. When you run the New Application Client wizard, the
deploytool utility automatically creates the JAR file and stores it in the application's EAR file. Defined by the J2EE Specification, the JAR file is portable across all compliant J2EE servers.The second JAR file contains stub classes that are required by the client program at runtime. These stub classes enable the client to access the enterprise beans that are running in the J2EE server. Because this second JAR file is not covered by the J2EE Specification, it is implementation specific, intended only for the J2EE SDK.
The J2EE application client source code is in
j2eetutorial/examples/src/ejb/converter/ConverterClient.java. You already compiled this code along with the enterprise bean code in the section Compiling the Source Files.Coding the J2EE Application Client
The
ConverterClient.java source code illustrates the basic tasks performed by the client of an enterprise bean:Locating the Home Interface
The
ConverterHome interface defines life-cycle methods such as create. Before the ConverterClient can invoke the create method, it must locate and instantiate an object whose type is ConverterHome. This is a four-step process.- Create an initial naming context.
Context initial = new InitialContext();
- The
Contextinterface is part of the Java Naming and Directory Interface (JNDI). A naming context is a set of name-to-object bindings. A name that is bound within a context is the JNDI name of the object. - An
InitialContextobject, which implements theContextinterface, provides the starting point for the resolution of names. All naming operations are relative to a context.
- The
- Obtain the environment naming context of the application client.
Context myEnv = (Context)initial.lookup("java:comp/env"); - Retrieve the object bound to the name
ejb/SimpleConverter.Object objref = myEnv.lookup("ejb/SimpleConverter"); - Narrow the reference to a
ConverterHomeobject.ConverterHome home =
(ConverterHome) PortableRemoteObject.narrow(objref,
ConverterHome.class);
Creating an Enterprise Bean Instance
To create the bean instance, the client invokes the
create method on the ConverterHome object. The create method returns an object whose type is Converter. The remote Converter interface defines the business methods of the bean that the client may call. When the client invokes the create method, the EJB container instantiates the bean and then invokes the ConverterBean.ejbCreate method. The client invokes the createmethod as follows:Converter currencyConverter = home.create();
Invoking a Business Method
Calling a business method is easy--you simply invoke the method on the
Converter object. The EJB container will invoke the corresponding method on the ConverterEJB instance that is running on the server. The client invokes the dollarToYen business method in the following lines of code.BigDecimal param = new BigDecimal ("100.00");
BigDecimal amount = currencyConverter.dollarToYen(param);
ConverterClient Source Code
The full source code for the
ConverterClient program follows.import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.math.BigDecimal;
public class ConverterClient {
public static void main(String[] args) {
try {
Context initial = new InitialContext();
Object objref = initial.lookup
("java:comp/env/ejb/SimpleConverter");
ConverterHome home =
(ConverterHome)PortableRemoteObject.narrow(objref,
ConverterHome.class);
Converter currencyConverter = home.create();
BigDecimal param = new BigDecimal ("100.00");
BigDecimal amount =
currencyConverter.dollarToYen(param);
System.out.println(amount);
amount = currencyConverter.yenToEuro(param);
System.out.println(amount);
System.exit(0); } catch (Exception ex) {
System.err.println("Caught an unexpected exception!");
ex.printStackTrace();
}
}
}
Compiling the Application Client
The application client files are compiled at the same time as the enterprise bean files, as described in Compiling the Source Files.
Packaging the J2EE Application Client
To package an application client component, you run the New Application Client wizard of the
deploytool. During this process the wizard performs the following tasks.- Creates the application client's deployment descriptor
- Puts the deployment descriptor and client files into a JAR file
- Adds the JAR file to the application's
ConverterApp.earfile
After the packaging process you can view the deployment descriptor by selecting Tools
To start the New Application Client wizard, select File
- Introduction dialog box
- JAR File Contents dialog box
- In the combo box, select
ConverterApp. - Click Edit.
- In the tree under Available Files, locate the
j2eetutorial/examples/build/ejb/converterdirectory. - Select the
ConverterClient.classfile and click Add. - Click OK.
- Click Next.
- In the combo box, select
- General dialog box
- In the Main Class combo box, select
ConverterClient. - Verify that the entry in the Display Name field is
ConverterClient. - In the Callback Handler Class combo box, select container-managed authentication.
- Click Next.
- Click Finish.
- In the Main Class combo box, select
Specifying the Application Client's Enterprise Bean Reference
When it invokes the
lookup method, the ConverterClient refers to the home of an enterprise bean:Object objref = myEnv.lookup("ejb/SimpleConverter");
You specify this reference as follows.
- In the tree, select
ConverterClient. - Select the EJB Refs tab.
- Click Add.
- In the Coded Name column, enter
ejb/SimpleConverter. - In the Type column, select Session.
- In the Interfaces column, select Remote.
- In the Home Interface column, enter
ConverterHome. - In the Local/Remote Interface column, enter
Converter.
Labels:
client source code,
Enterprise JavaBean,
enterprise-it,
J2EE,
JAR,
java,
Java Naming and Directory Interface,
Java Platform Enterprise Edition,
java programming language,
java source code,
Languages,
Programming,
software,
Source code,
technology
Monday, June 11, 2012
JumpCut
Jumpcut is an application that provides “clipboard buffering” — that is, access to text that you’ve cut or copied, even if you’ve subsequently cut or copied something else. The goal of Jumpcut’s interface is to provide quick, natural, intuitive access to your clipboard’s history. The application is available as a Universal Binary that requires OS X 10.3.9 or later. Users running earlier versions of OS X should try Jumpcut 0.54, which should work with OS X 10.1 and later. Source code is also available. Jumpcut is open sourced under the MIT License.
Top 10 Internet tips and tricks
You don't need the http:// portion of a web page
When typing an Internet address you do not need to type http:// or even www. in the address. For example, if you wanted to visit Computer Hope you could just type computerhope.com and press enter. To make things even quicker, if you're visiting a .com address you can type computerhope and then press Ctrl + Enter to type out the full http://www.computerhope.com address.
Quickly move between the fields of a web page
If you're filling out an online form, e-mail, or other text field you can quickly move between each of the fields by pressing the Tab key or Shift + Tab to move back a field. For example, if you're filling out your name and the next field is your e-mail address you can press the Tab key to switch to the e-mail field.
Tip: This tip also applies to the buttons, if you press tab and the web developer has designed correctly the button should be selected and will allow you to press the space bar or enter to push the button.
Tip: If you have a drop-down box that lists every country or every state you can click that box and then press the letter of the state or country you're looking for. For example, is a drop-down box of States in the United States you could press u on the keyboard to quickly scroll to Utah.
Use Internet search engines to their full potential
Make sure to get the most out of every search result. If you're not finding what you want try surrounding the text in quotes. For example, if you were searching for 'computer help' this actually searches for pages that contain both computer and help and not necessarily pages that have computer and help next to each other. If you search for "computer help" with the quotes around the search query this will only return pages that actually have computer and help next to each other.
Tip: Many new computer users also don't realize that in every search box you can press enter instead of having to move the mouse button over to the Search button.
Protect yourself and avoid bad web sites
Know your Internet browser shortcuts
There are dozens of different shortcut keys that can be used with Internet browsers. Below are a few of our top suggested Internet browser shortcuts.
- Pressing Alt + D in any major Internet browser will move the cursor into the address bar. This is a great way to quickly enter an Internet address without having to click the mouse cursor in the address bar.
- Hold down the Ctrl key and press the + or - to increase and decrease the size of text.
- Press the backspace key or hold down the Alt key + left arrow to go back a page.
- Press F5 to refresh or reload a web page.
- Press F11 to make the Internet browser screen full screen.
- Press Ctrl + B to open your Internet bookmarks.
- Press Ctrl + F to open the find box in the browser to search for text within the web page you're looking at.
Take advantage of tabbed browsing
Take full advantage of tabbed browsing in all Internet browsers today. While reading any web page if you come across a link you may be interested in open that link in a new tab so it can be viewed later. A new tab can be opened by holding down the Ctrl key and clicking the link or if you have a mouse with a wheel click the link with the middle mouse button.
Try alternative browsers
Most computer users use the default browser that comes included with the computer, with Microsoft Windows this is Internet Explorer. There are several great alternative browsers that are all free to download and use and may have features your current browser does not include. Below are a few of our favorites, try one or try them all.
Install plugins and add-ons
Each of the above alternative browsers also have a large community of volunteers who develop add-ons and plugins that can be added into the browser. Each of these browsers have hundreds of thousands of these add-ons that can do such things as giving you live weather in your browser window, changing its color, and adding additional functionality.
Make sure your browser and its plugins are up-to-date
Each Internet browser can have several additional plugins that give it additional functionality. For example, Adobe Flash is a great way to bring movies and other animated content to the Internet. Keeping these plugins up-to-date is vital for your computer stability and also security. Using the below tool you can quickly verify if your plugins are up-to-date and get links to where to download the latest updates.
Use online services
There are hundreds of free online services that can help make using your computer easier, more productive, and more enjoyable. See our top 10 online services for a listing of our favorites.
When typing an Internet address you do not need to type http:// or even www. in the address. For example, if you wanted to visit Computer Hope you could just type computerhope.com and press enter. To make things even quicker, if you're visiting a .com address you can type computerhope and then press Ctrl + Enter to type out the full http://www.computerhope.com address.
Quickly move between the fields of a web page
If you're filling out an online form, e-mail, or other text field you can quickly move between each of the fields by pressing the Tab key or Shift + Tab to move back a field. For example, if you're filling out your name and the next field is your e-mail address you can press the Tab key to switch to the e-mail field.
Tip: This tip also applies to the buttons, if you press tab and the web developer has designed correctly the button should be selected and will allow you to press the space bar or enter to push the button.
Tip: If you have a drop-down box that lists every country or every state you can click that box and then press the letter of the state or country you're looking for. For example, is a drop-down box of States in the United States you could press u on the keyboard to quickly scroll to Utah.
Use Internet search engines to their full potential
Make sure to get the most out of every search result. If you're not finding what you want try surrounding the text in quotes. For example, if you were searching for 'computer help' this actually searches for pages that contain both computer and help and not necessarily pages that have computer and help next to each other. If you search for "computer help" with the quotes around the search query this will only return pages that actually have computer and help next to each other.
Tip: Many new computer users also don't realize that in every search box you can press enter instead of having to move the mouse button over to the Search button.
Protect yourself and avoid bad web sites
- How can I protect myself while online?
- Avoid Internet phishing.
- Protecting children from harmful material and people on the Internet.
Know your Internet browser shortcuts
There are dozens of different shortcut keys that can be used with Internet browsers. Below are a few of our top suggested Internet browser shortcuts.
- Pressing Alt + D in any major Internet browser will move the cursor into the address bar. This is a great way to quickly enter an Internet address without having to click the mouse cursor in the address bar.
- Hold down the Ctrl key and press the + or - to increase and decrease the size of text.
- Press the backspace key or hold down the Alt key + left arrow to go back a page.
- Press F5 to refresh or reload a web page.
- Press F11 to make the Internet browser screen full screen.
- Press Ctrl + B to open your Internet bookmarks.
- Press Ctrl + F to open the find box in the browser to search for text within the web page you're looking at.
Take advantage of tabbed browsing
Take full advantage of tabbed browsing in all Internet browsers today. While reading any web page if you come across a link you may be interested in open that link in a new tab so it can be viewed later. A new tab can be opened by holding down the Ctrl key and clicking the link or if you have a mouse with a wheel click the link with the middle mouse button.
Try alternative browsers
Most computer users use the default browser that comes included with the computer, with Microsoft Windows this is Internet Explorer. There are several great alternative browsers that are all free to download and use and may have features your current browser does not include. Below are a few of our favorites, try one or try them all.
Install plugins and add-ons
Each of the above alternative browsers also have a large community of volunteers who develop add-ons and plugins that can be added into the browser. Each of these browsers have hundreds of thousands of these add-ons that can do such things as giving you live weather in your browser window, changing its color, and adding additional functionality.
Make sure your browser and its plugins are up-to-date
Each Internet browser can have several additional plugins that give it additional functionality. For example, Adobe Flash is a great way to bring movies and other animated content to the Internet. Keeping these plugins up-to-date is vital for your computer stability and also security. Using the below tool you can quickly verify if your plugins are up-to-date and get links to where to download the latest updates.
Use online services
There are hundreds of free online services that can help make using your computer easier, more productive, and more enjoyable. See our top 10 online services for a listing of our favorites.
C interview questions and answers
- What will print out?main()
{
char *p1=“name”;
char *p2;
p2=(char*)malloc(20);
memset (p2, 0, 20);
while(*p2++ = *p1++);
printf(“%sn”,p2);
}
Answer:empty string. - What will be printed as the result of the operation below:
main()
{
int x=20,y=35;
x=y++ + x++;
y= ++y + ++x;
printf(“%d%dn”,x,y);}
Answer : 5794 - What will be printed as the result of the operation below:
main()
{
int x=5;
printf(“%d,%d,%dn”,x,x< <2,x>>2);}
Answer: 5,20,1 - What will be printed as the result of the operation below:
#define swap(a,b) a=a+b;b=a-b;a=a-b;void main()
{
int x=5, y=10;
swap (x,y);
printf(“%d %dn”,x,y);
swap2(x,y);
printf(“%d %dn”,x,y);
}
int swap2(int a, int b)
{
int temp;
temp=a;
b=a;
a=temp;
return 0;
}
Answer: 10, 5
10, 5 - What will be printed as the result of the operation below:
main()
{
char *ptr = ” Cisco Systems”;
*ptr++; printf(“%sn”,ptr);
ptr++;
printf(“%sn”,ptr);}
Answer:Cisco Systems
isco systems - What will be printed as the result of the operation below:
main()
{
char s1[]=“Cisco”;
char s2[]= “systems”;
printf(“%s”,s1);
}
Answer: Cisco - What will be printed as the result of the operation below:
main()
{
char *p1;
char *p2; p1=(char *)malloc(25);
p2=(char *)malloc(25);
strcpy(p1,”Cisco”);
strcpy(p2,“systems”);
strcat(p1,p2);
printf(“%s”,p1);
}
Answer: Ciscosystems - The following variable is available in file1.c, who can access it?:
static int average;
Answer: all the functions in the file1.c can access the variable. - WHat will be the result of the following code?
#define TRUE 0 // some codewhile(TRUE)
{
// some code
}
Answer: This will not go into the loop as TRUE is defined as 0. - What will be printed as the result of the operation below:
int x;
int modifyvalue()
{
return(x+=10);
}int changevalue(int x)
{
return(x+=1);
}
void main()
{
int x=10;
x++;
changevalue(x);
x++;
modifyvalue();
printf("First output:%dn",x);
x++;
changevalue(x);
printf("Second output:%dn",x);
modifyvalue();
printf("Third output:%dn",x);
}
Answer: 12 , 13 , 13 - What will be printed as the result of the operation below:
main()
{
int x=10, y=15;
x = x++;
y = ++y;
printf(“%d %dn”,x,y);}
Answer: 11, 16 - What will be printed as the result of the operation below:
main()
{
int a=0;
if(a==0)
printf(“Cisco Systemsn”);
printf(“Cisco Systemsn”);}
Answer: Two lines with “Cisco Systems” will be printed.
Wednesday, May 30, 2012
J2EE Tutorial-9(Creating the Enterprise Bean)
An enterprise bean is a server-side component that contains the business logic of an application. At runtime, the application clients execute the business logic by invoking the enterprise bean's methods. The enterprise bean in our example is a stateless session bean called
The enterprise bean in this example requires the following code:
A remote interface defines the business methods that a client may call. The business methods are implemented in the enterprise bean code. The source code for the
A home interface defines the methods that allow a client to create, find, or remove an enterprise bean. The
The enterprise bean class for this example is called
Now you are ready to compile the remote interface (
This command compiles the source files for the enterprise bean and the J2EE application client. It places the resulting class files in the
Note: When compiling the code, the preceding
To package an enterprise bean, you run the New Enterprise Bean wizard of the
After the packaging process, you can view the deployment descriptor by selecting Tools
Descriptor Viewer.
To start the New Enterprise Bean wizard, select File
New
Enterprise Bean. The wizard displays the following dialog boxes.
ConverterEJB. The source code for ConverterEJB is in thej2eetutorial/examples/src/ejb/converter directory.Coding the Enterprise Bean
The enterprise bean in this example requires the following code:
- Remote interface
- Home interface
- Enterprise bean class
Coding the Remote Interface
A remote interface defines the business methods that a client may call. The business methods are implemented in the enterprise bean code. The source code for the
Converter remote interface follows.import javax.ejb.EJBObject;
import java.rmi.RemoteException;
import java.math.*;
public interface Converter extends EJBObject {
public BigDecimal dollarToYen(BigDecimal dollars)
throws RemoteException;
public BigDecimal yenToEuro(BigDecimal yen)
throws RemoteException;
}
Coding the Home Interface
A home interface defines the methods that allow a client to create, find, or remove an enterprise bean. The
ConverterHome interface contains a single create method, which returns an object of the remote interface type. Here is the source code for the ConverterHome interface:import java.io.Serializable;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
public interface ConverterHome extends EJBHome {
Converter create() throws RemoteException, CreateException;
}
Coding the Enterprise Bean Class
The enterprise bean class for this example is called
ConverterBean. This class implements the two business methods, dollarToYen and yenToEuro, that the Converter remote interface defines. The source code for the ConverterBean class follows.import java.rmi.RemoteException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import java.math.*;
public class ConverterBean implements SessionBean {
BigDecimal yenRate = new BigDecimal("121.6000");
BigDecimal euroRate = new BigDecimal("0.0077");
public BigDecimal dollarToYen(BigDecimal dollars) {
BigDecimal result = dollars.multiply(yenRate);
return result.setScale(2,BigDecimal.ROUND_UP);
} public BigDecimal yenToEuro(BigDecimal yen) {
BigDecimal result = yen.multiply(euroRate);
return result.setScale(2,BigDecimal.ROUND_UP);
} public ConverterBean() {}
public void ejbCreate() {}
public void ejbRemove() {}
public void ejbActivate() {}
public void ejbPassivate() {}
public void setSessionContext(SessionContext sc) {}
}
Compiling the Source Files
Now you are ready to compile the remote interface (
Converter.java), home interface (ConverterHome.java), and the enterprise bean class (ConverterBean.java).- In a terminal window, go to the
j2eetutorial/examplesdirectory. - Type the following command:
ant converter
This command compiles the source files for the enterprise bean and the J2EE application client. It places the resulting class files in the
j2eetutorial/examples/build/ejb/converter directory (not the src directory). For more information about ant, see How to Build and Run the Examples.Note: When compiling the code, the preceding
ant task includes the j2ee.jar file in the classpath. This file resides in the lib directory of your J2EE SDK installation. If you plan on using other tools to compile the source code for J2EE components, make sure that the classpath includes the j2ee.jar file.Packaging the Enterprise Bean
To package an enterprise bean, you run the New Enterprise Bean wizard of the
deploytool utility. During this process, the wizard performs the following tasks:- Creates the bean's deployment descriptor
- Packages the deployment descriptor and the bean's classes in an EJB JAR file
- Inserts the EJB JAR file into the application's
ConverterApp.earfile
After the packaging process, you can view the deployment descriptor by selecting Tools
To start the New Enterprise Bean wizard, select File
- Introduction dialog box
- EJB JAR dialog box
- Select the Create New JAR File In Application button.
- In the combo box, select
ConverterApp. - In the JAR Display Name field, enter
ConverterJAR. - Click Edit.
- In the tree under Available Files, locate the
j2eetutorial/examples/build/ejb/converterdirectory. (If theconverterdirectory is many levels down in the tree, you can simplify the tree view by entering all or part of theconverterdirectory's path name in the Starting Directory field.) - Select the following classes from the Available Files tree and click Add:
Converter.class,ConverterBean.class, andConverterHome.class. (You may also drag and drop these class files to the Contents text area.) - Click OK.
- Click Next.
- General dialog box
- Under Bean Type, select the Session radio button.
- Select the Stateless radio button.
- In the Enterprise Bean Class combo box, select
ConverterBean. - In the Enterprise Bean Name field, enter
ConverterEJB. - In the Remote Home Interface combo box, select
ConverterHome. - In the Remote Interface combo box, select
Converter. - Click Next.
- Transaction Management dialog box
J2EE Tutorial-8 (Creating the J2EE Application)
The sample application contains three J2EE components: an enterprise bean, a J2EE application client, and a Web component. Before building these components, you will create a new J2EE application called
ConverterApp and will store it in an EAR file named ConverterApp.ear.- In
deploytool, select FileNew
Application.
- Click Browse.
- In the file chooser, navigate to
j2eetutorial/examples/src/ejb/converter. - In the File Name field, enter
ConverterApp.ear. - Click New Application.
- Click OK.
J2EE Tutorial-7 (Setting up Environment)
Before you start developing the example application, you should follow the instructions in this section.
The source code for the components is in
To build the example code, you'll need installations of the J2EE SDK and
The installation instructions for the J2EE SDK and
To launch the J2EE server, open a terminal window and type this command:
Although not required, the
To stop the server, type the following command:
The
Getting the Example Code
The source code for the components is in
j2eetutorial/examples/src/ejb/converter, a directory that is created when you unzip the tutorial bundle. If you are viewing this tutorial online, you need to download the tutorial bundle fromhttp://java.sun.com/j2ee/download.html#tutorial
Getting the Build Tool (ant)
To build the example code, you'll need installations of the J2EE SDK and
ant, a portable make tool. For more information, see the section How to Build and Run the Examples.Checking the Environment Variables
The installation instructions for the J2EE SDK and
ant explain how to set the required environment variables. Verify that the environment variables have been set to the values noted inTable 2-1.| Environment Variable | Value |
|---|---|
JAVA_HOME | The location of the J2SE SDK installation |
J2EE_HOME | The location of the J2EE SDK installation |
ANT_HOME | The location of the ant installation |
PATH | Should include the bin directories of the J2EE SDK, J2SE, and ant installations |
Starting the J2EE Server
To launch the J2EE server, open a terminal window and type this command:
j2ee -verbose
Although not required, the
verbose option is useful for debugging.To stop the server, type the following command:
j2ee -stop
Starting the deploytool
The
deploytool utility has two modes: command line and GUI. The instructions in this chapter refer to the GUI version. To start the deploytool GUI, open a terminal window and type this command:deploytool
Tuesday, May 29, 2012
J2EE Tutorial -1 (overview)
Today, more and more developers want to write distributed transactional applications for the enterprise and leverage the speed, security, and reliability of server-side technology. If you are already working in this area, you know that in today's fast-moving and demanding world of e-commerce and information technology, enterprise applications have to be designed, built, and produced for less money, with greater speed, and with fewer resources than ever before.
To reduce costs and fast-track enterprise application design and development, the Java
2 Platform, Enterprise Edition (J2EE
) technology provides a component-based approach to the design, development, assembly, and deployment of enterprise applications. The J2EE platform offers a multitiered distributed application model, the ability to reuse components, integrated Extensible Markup Language (XML)-based data interchange, a unified security model, and flexible transaction control. Not only can you deliver innovative customer solutions to market faster than ever, but your platform-independent J2EE component-based solutions are not tied to the products and application programming interfaces (APIs) of any one vendor. Vendors and customers enjoy the freedom to choose the products and components that best meet their business and technological requirements.
This tutorial takes an examples-based approach to describing the features and functionalities available in J2EE Software Development Kit (SDK) version 1.3. Whether you are a new or an experienced enterprise developer, you should find the examples and accompanying text a valuable and accessible knowledge base for creating your own enterprise solutions.
If you are new to J2EE applications development, this chapter is a good place to start. Here you will learn the J2EE architecture, become acquainted with important terms and concepts, and find out how to approach J2EE application programming, assembly, and deployment.
To reduce costs and fast-track enterprise application design and development, the Java
This tutorial takes an examples-based approach to describing the features and functionalities available in J2EE Software Development Kit (SDK) version 1.3. Whether you are a new or an experienced enterprise developer, you should find the examples and accompanying text a valuable and accessible knowledge base for creating your own enterprise solutions.
If you are new to J2EE applications development, this chapter is a good place to start. Here you will learn the J2EE architecture, become acquainted with important terms and concepts, and find out how to approach J2EE application programming, assembly, and deployment.
"Go" Language Tutorial-2 (offline Go)
This tour is also available as a stand-alone program that you can use without access to the internet.
The stand-alone tour is faster, as it builds and runs the code samples on your own machine. It also includes additional exercises not available in this sandboxed version.
To run the tour locally first install Go, then use go get to install gotour:
and run the resultant
Otherwise, click the "next" button or type PageDown to continue.
(You may return to these instructions at any time by clicking the "index" button.)
The stand-alone tour is faster, as it builds and runs the code samples on your own machine. It also includes additional exercises not available in this sandboxed version.
To run the tour locally first install Go, then use go get to install gotour:
go get code.google.com/p/go-tour/gotour
and run the resultant
gotour executable.Otherwise, click the "next" button or type PageDown to continue.
(You may return to these instructions at any time by clicking the "index" button.)
"Go" Language Tutorial-1
Welcome to a tour of the Go programming language.
The tour is divided into three sections. At the end of each section is a series of exercises for you to complete.
The tour is interactive. Click the Run button now (or type Shift-Enter) to compile and run the program on a remote server. The result is displayed below the code.
These example programs demonstrate different aspects of Go. The programs in the tour are meant to be starting points for your own experimentation.
Edit the program and run it again.
Whenever you're ready to move on, click the Next button or type the PageDown key.
Example:
package main
import "fmt"
func main() {
fmt.Println("Hello, 世界")
}
output :
The tour is divided into three sections. At the end of each section is a series of exercises for you to complete.
The tour is interactive. Click the Run button now (or type Shift-Enter) to compile and run the program on a remote server. The result is displayed below the code.
These example programs demonstrate different aspects of Go. The programs in the tour are meant to be starting points for your own experimentation.
Edit the program and run it again.
Whenever you're ready to move on, click the Next button or type the PageDown key.
Example:
package main
import "fmt"
func main() {
fmt.Println("Hello, 世界")
}
output :
Hello, 世界
Receiving mail with attachment using javamail API
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import java.io.*;
class ReadAttachment{
public static void main(String [] args)throws Exception{
String host="mail.javatpoint.com";
final String user="sonoojaiswal@javatpoint.com";
final String password="xxxxx";//change accordingly
Properties properties = System.getProperties();
properties.setProperty("mail.smtp.host",host );
properties.put("mail.smtp.auth", "true");
Session session = Session.getDefaultInstance(properties,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user,password);
}
});
Store store = session.getStore("pop3");
store.connect(host,user,password);
Folder folder = store.getFolder("inbox");
folder.open(Folder.READ_WRITE);
Message[] message = folder.getMessages();
for (int a = 0; a < message.length; a++) {
System.out.println("-------------" + (a + 1) + "-----------");
System.out.println(message[a].getSentDate());
Multipart multipart = (Multipart) message[a].getContent();
for (int i = 0; i < multipart.getCount(); i++) {
BodyPart bodyPart = multipart.getBodyPart(i);
InputStream stream = bodyPart.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(stream));
while (br.ready()) {
System.out.println(br.readLine());
}
System.out.println();
}
System.out.println();
}
folder.close(true);
store.close();
}
}
LOAD THE JAR FILE : C:\> set classpath=mail.jar;activation.jar;
COMPILE THE SOURCE FILE: C:\> javac ReadAttachment.java
RUN BY :C:\> java ReadAttachment
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import java.io.*;
class ReadAttachment{
public static void main(String [] args)throws Exception{
String host="mail.javatpoint.com";
final String user="sonoojaiswal@javatpoint.com";
final String password="xxxxx";//change accordingly
Properties properties = System.getProperties();
properties.setProperty("mail.smtp.host",host );
properties.put("mail.smtp.auth", "true");
Session session = Session.getDefaultInstance(properties,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user,password);
}
});
Store store = session.getStore("pop3");
store.connect(host,user,password);
Folder folder = store.getFolder("inbox");
folder.open(Folder.READ_WRITE);
Message[] message = folder.getMessages();
for (int a = 0; a < message.length; a++) {
System.out.println("-------------" + (a + 1) + "-----------");
System.out.println(message[a].getSentDate());
Multipart multipart = (Multipart) message[a].getContent();
for (int i = 0; i < multipart.getCount(); i++) {
BodyPart bodyPart = multipart.getBodyPart(i);
InputStream stream = bodyPart.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(stream));
while (br.ready()) {
System.out.println(br.readLine());
}
System.out.println();
}
System.out.println();
}
folder.close(true);
store.close();
}
}
LOAD THE JAR FILE : C:\> set classpath=mail.jar;activation.jar;
COMPILE THE SOURCE FILE: C:\> javac ReadAttachment.java
RUN BY :C:\> java ReadAttachment
Subscribe to:
Posts (Atom)