tag:blogger.com,1999:blog-27038645377824128322024-03-13T06:45:07.832+05:30Java Developer SolutionsArunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.comBlogger26125tag:blogger.com,1999:blog-2703864537782412832.post-2278137366130699592012-08-15T22:15:00.000+05:302012-08-15T23:57:05.164+05:30Strophe fix for JabberHttpBindingServlet <a href="http://strophe.im/strophejs/">Strophe.js</a> is best xmpp bosh library , but we found problem with <a href="http://stefan-strigler.de/jhb/">JabberHttpBindingServlet </a> connection ,i tried lot of hours for searching the solution from google , but no luck ,so myself dig the code after nearly one hour i got it . The problem is JHBServlet is expeting child node or empty child node form XMPP_RESTART body tag,but strophe is sending self-closed body tag
<br />
<br />
<b><span style="font-size: large;">Solution : strophe.js</span></b><br />
<br />
<span style="color: #0b5394; font-family: Courier New, Courier, monospace;"><b>if (this._data[i] === "restart") {</b></span><br />
<span style="color: #0b5394; font-family: Courier New, Courier, monospace;"><b> body.attrs({</b></span><br />
<span style="color: #0b5394; font-family: Courier New, Courier, monospace;"><b> to: this.domain,</b></span><br />
<span style="color: #0b5394; font-family: Courier New, Courier, monospace;"><b> "xml:lang": "en",</b></span><br />
<span style="color: #0b5394; font-family: Courier New, Courier, monospace;"><b> "xmpp:restart": "true",</b></span><br />
<span style="color: #0b5394; font-family: Courier New, Courier, monospace;"><b> "xmlns:xmpp": Strophe.NS.BOSH</b></span><br />
<span style="color: #0b5394; font-family: Courier New, Courier, monospace;"><b> });</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><b><span style="color: #0b5394;"> </span><span style="color: #cc0000;">body.t(' '); //Solution </span><span style="color: #0b5394;"> </span></b></span><br />
<span style="color: #0b5394; font-family: Courier New, Courier, monospace;"><b> } else {</b></span><br />
<span style="color: #0b5394; font-family: Courier New, Courier, monospace;"><b> body.cnode(this._data[i]).up();</b></span><br />
<span style="color: #0b5394; font-family: Courier New, Courier, monospace;"><b> }</b></span><br />
<span style="color: #0b5394; font-family: Courier New, Courier, monospace;"><b><br /></b></span>
<span style="color: #0b5394; font-family: Courier New, Courier, monospace;"><b>or download modified source </b></span><b style="color: #0b5394; font-family: 'Courier New', Courier, monospace;"><a href="http://www.javaorigin.com/tutorials/63/25/81/source/strophe.js">Strophe.js</a></b>Arunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com1tag:blogger.com,1999:blog-2703864537782412832.post-60035765335091799432008-06-27T19:18:00.000+05:302008-06-27T19:28:34.116+05:30Blob problem (oracle)Problem<br /> code: st.setBinaryStream(1,streamData,data.length)<br /> while inserting blob .it will throw<br />ORA-01460: <b>unimplemented or unreasonable conversion requested </b> Exception<br /><br />Problem root<br /> oracle driver problem (ojdbc14.jar) if you are using oracle 9 driver or minor version driver (ojdbc14.jar) .it will happen<br /><br />Solution<br /><br /> please download corresponding latest driver from oracle websiteArunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com2tag:blogger.com,1999:blog-2703864537782412832.post-84373076735641248162008-06-27T18:48:00.000+05:302008-06-27T19:01:57.443+05:30XmlBeans - ClassCastExceptionproblem<br /> while creating bean instance .it will throw<br />Exception in thread "main" java.lang.ClassCastException: com.javaorigin.xmlBean.SampleBean at com.javaorigin.xmlBean.SampleBean.SampleComplexBean.Factory.newInstance(Unknown Source)<br /><br />Problem Root<br /> This is java major and minor version problem .if you are using xmlbean 2.2.0 with jdk1.4.x<br />then it will happen<br /><br />Solution<br /> use latest jdk for compiling scemas (ex: use xmlBean2.2.0 with jdk1.5 )Arunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com1tag:blogger.com,1999:blog-2703864537782412832.post-91724266390986372772007-08-23T17:12:00.000+05:302007-08-23T22:26:01.030+05:30create a datasource from a stream using JMF<span id="intelliTxt">Two things you need before you can do this. First, you need to take the stream and convert it to a byte buffer (easy enough). Secondly, you need to know the content type of the stream<br /><br /></span><span style="color: rgb(255, 0, 0);" id="intelliTxt">import javax.media.protocol.ContentDescriptor;<br />import javax.media.protocol.PullDataSource;<br /><br />import java.nio.ByteBuffer;<br />import java.io.IOException;<br /><br />import javax.media.MediaLocator;<br />import javax.media.Duration;<br />import javax.media.Time;<br /><br /><br />/**<br />*<br />* @author Chad McMillan<br />*/<br /><br />public class ByteBufferDataSource extends PullDataSource {<br /> <br /> protected ContentDescriptor contentType;<br /> protected SeekableStream[] sources;<br /> protected boolean connected;<br /> protected ByteBuffer anInput;<br /> <br /> protected ByteBufferDataSource(){<br /> }<br /> <br /> /**<br /> * Construct a <code>ByteBufferDataSource</code> from a <code>ByteBuffer</code>.<br /> * @param source The <code>ByteBuffer</code> that is used to create the<br /> * the <code>DataSource</code>.<br /> */<br /> public ByteBufferDataSource(ByteBuffer input, String contentType) throws IOException {<br /> anInput = input;<br /> this.contentType = new ContentDescriptor(contentType);<br /> connected = false;<br /> }<br /> <br /> /**<br /> * Open a connection to the source described by<br /> * the <code>ByteBuffer/CODE>.<br /> * </code><p><br /> *<br /> * The <code>connect</code> method initiates communication with the source.<br /> *<br /> * @exception IOException Thrown if there are IO problems<br /> * when <code>connect</code> is called.<br /> */<br /> public void connect() throws java.io.IOException {<br /> connected = true;<br /> sources = new SeekableStream [1];<br /> sources[0] = new SeekableStream(anInput);<br /> }<br /> <br /> /**<br /> * Close the connection to the source described by the locator.<br /> * </p><p><br /> * The <code>disconnect</code> method frees resources used to maintain a<br /> * connection to the source.<br /> * If no resources are in use, <code>disconnect</code> is ignored.<br /> * If <code>stop</code> hasn't already been called,<br /> * calling <code>disconnect</code> implies a stop.<br /> *<br /> */<br /> public void disconnect() {<br /> if(connected) {<br /> sources[0].close();<br /> connected = false;<br /> }<br /> }<br /> <br /> /**<br /> * Get a string that describes the content-type of the media<br /> * that the source is providing.<br /> * </p><p><br /> * It is an error to call <code>getContentType</code> if the source is<br /> * not connected.<br /> *<br /> * @return The name that describes the media content.<br /> */<br /> public String getContentType() {<br /> if( !connected) {<br /> throw new java.lang.Error("Source is unconnected.");<br /> }<br /> return contentType.getContentType();<br /> }<br /> <br /> public Object getControl(String str) {<br /> return null;<br /> }<br /> <br /> public Object[] getControls() {<br /> return new Object[0];<br /> }<br /> <br /> public javax.media.Time getDuration() {<br /> return Duration.DURATION_UNKNOWN;<br /> }<br /> <br /> /**<br /> * Get the collection of streams that this source<br /> * manages. The collection of streams is entirely<br /> * content dependent. The MIME type of this<br /> * <code>DataSource</code> provides the only indication of<br /> * what streams can be available on this connection.<br /> *<br /> * @return The collection of streams for this source.<br /> */<br /> public javax.media.protocol.PullSourceStream[] getStreams() {<br /> if( !connected) {<br /> throw new java.lang.Error("Source is unconnected.");<br /> }<br /> return sources;<br /> }<br /> <br /> /**<br /> * Initiate data-transfer. The <code>start</code> method must be<br /> * called before data is available.<br /> *(You must call <code>connect</code> before calling <code>start</code>.)<br /> *<br /> * @exception IOException Thrown if there are IO problems with the source<br /> * when <code>start</code> is called.<br /> */<br /> public void start() throws IOException {<br /> }<br /> <br /> /**<br /> * Stop the data-transfer.<br /> * If the source has not been connected and started,<br /> * <code>stop</code> does nothing.<br /> */<br /> public void stop() throws IOException {<br /> }<br />}<br /><br />(and for your stream)<br /><br />import java.lang.reflect.Method;<br />import java.lang.reflect.Constructor;<br /><br />import java.io.IOException;<br />import java.nio.ByteBuffer;<br />import java.nio.BufferUnderflowException;<br /><br /><br />import javax.media.protocol.PullSourceStream;<br />import javax.media.protocol.Seekable;<br />import javax.media.protocol.ContentDescriptor;<br />/**<br />*<br />* @author Chad McMillan<br />*/<br />public class SeekableStream implements PullSourceStream, Seekable {<br /> <br /> <br /> protected ByteBuffer inputBuffer;<br /><br /> /**<br /> * a flag to indicate EOF reached<br /> */<br /> <br /> <br /> /** Creates a new instance of SeekableStream */<br /> public SeekableStream(ByteBuffer byteBuffer) {<br /> inputBuffer = byteBuffer;<br /> this.seek((long)(0)); // set the ByteBuffer to to beginning<br /> }<br /> <br /> /**<br /> * Find out if the end of the stream has been reached.<br /> *<br /> * @return Returns <code>true</code> if there is no more data.<br /> */<br /> public boolean endOfStream() {<br /> return (! inputBuffer.hasRemaining());<br /> }<br /> <br /> /**<br /> * Get the current content type for this stream.<br /> *<br /> * @return The current <code>ContentDescriptor</code> for this stream.<br /> */<br /> public ContentDescriptor getContentDescriptor() {<br /> return null;<br /> }<br /> <br /> /**<br /> * Get the size, in bytes, of the content on this stream.<br /> *<br /> * @return The content length in bytes.<br /> */<br /> public long getContentLength() {<br /> return inputBuffer.capacity();<br /> }<br /> <br /> /**<br /> * Obtain the object that implements the specified<br /> * <code>Class</code> or <code>Interface</code><br /> * The full class or interface name must be used.<br /> * </p><p><br /> *<br /> * The control is not supported.<br /> * <code>null</code> is returned.<br /> *<br /> * @return <code>null</code>.<br /> */<br /> public Object getControl(String controlType) {<br /> return null;<br /> }<br /> <br /> /**<br /> * Obtain the collection of objects that<br /> * control the object that implements this interface.<br /> * </p><p><br /> *<br /> * No controls are supported.<br /> * A zero length array is returned.<br /> *<br /> * @return A zero length array<br /> */<br /> public Object[] getControls() {<br /> Object[] objects = new Object[0];<br /><br /> return objects;<br /> }<br /> <br /> /**<br /> * Find out if this media object can position anywhere in the<br /> * stream. If the stream is not random access, it can only be repositioned<br /> * to the beginning.<br /> *<br /> * @return Returns <code>true</code> if the stream is random access, <code>false</code> if the stream can only<br /> * be reset to the beginning.<br /> */<br /> public boolean isRandomAccess() {<br /> return true;<br /> }<br /> <br /> /**<br /> * Block and read data from the stream.<br /> * </p><p><br /> * Reads up to <code>length</code> bytes from the input stream into<br /> * an array of bytes.<br /> * If the first argument is <code>null</code>, up to<br /> * <code>length</code> bytes are read and discarded.<br /> * Returns -1 when the end<br /> * of the media is reached.<br /> *<br /> * This method only returns 0 if it was called with<br /> * a <code>length</code> of 0.<br /> *<br /> * @param buffer The buffer to read bytes into.<br /> * @param offset The offset into the buffer at which to begin writing data.<br /> * @param length The number of bytes to read.<br /> * @return The number of bytes read, -1 indicating<br /> * the end of stream, or 0 indicating <code>read</code><br /> * was called with <code>length</code> 0.<br /> * @throws IOException Thrown if an error occurs while reading.<br /> */<br /> public int read(byte[] buffer, int offset, int length) throws IOException {<br /> <br /> // return n (number of bytes read), -1 (eof), 0 (asked for zero bytes)<br /> <br /> if ( length == 0 )<br /> return 0;<br /> try {<br /> inputBuffer.get(buffer,offset,length);<br /> return length;<br /> }<br /> catch ( BufferUnderflowException E ) {<br /> return -1;<br /> }<br /> }<br /> <br /> public void close() {<br /> <br /> }<br /> /**<br /> * Seek to the specified point in the stream.<br /> * @param where The position to seek to.<br /> * @return The new stream position.<br /> */<br /> public long seek(long where) {<br /> try {<br /> inputBuffer.position((int)(where));<br /> return where;<br /> }<br /> catch (IllegalArgumentException E) {<br /> return this.tell(); // staying at the current position<br /> }<br /> }<br /> <br /> /**<br /> * Obtain the current point in the stream.<br /> */<br /> public long tell() {<br /> return inputBuffer.position();<br /> }<br /> <br /> /**<br /> * Find out if data is available now.<br /> * Returns <code>true</code> if a call to <code>read</code> would block<br /> * for data.<br /> *<br /> * @return Returns <code>true</code> if read would block; otherwise<br /> * returns <code>false</code>.<br /> */<br /> public boolean willReadBlock() {<br /> return (inputBuffer.remaining() == 0);<br /> }<br />}<br /></p></span>Arunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com4tag:blogger.com,1999:blog-2703864537782412832.post-42869328177699222392007-08-16T19:34:00.000+05:302007-08-23T22:33:25.445+05:30Getting Session Object using Session Id (HttpServlet )HttpSessionContext is very usefull interface for getting all session objects using with session Id .<br /><br /><span style="font-weight: bold;"><span style="color: rgb(255, 0, 0);"> HttpSessionContext sc=request.getSession().getSessionContext();</span><br /><span style="color: rgb(255, 0, 0);"> HttpSession session=sc.getSession(session_id);</span><br /></span><br /><br />But In version 2.1 of the Servlet API the HttpSessionContext class was deprecated for security reasons by Sun, with no plans for a replacement. In short, steer clear of HttpSessionContextArunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com0tag:blogger.com,1999:blog-2703864537782412832.post-54492514605400244132007-08-02T10:37:00.000+05:302007-08-23T22:33:25.445+05:30Java Discussion Forum<a href="http://forum.javaorigin.com">http://forum.javaorigin.com</a>Arunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com0tag:blogger.com,1999:blog-2703864537782412832.post-84342027389217424352007-07-19T16:15:00.001+05:302007-08-23T22:33:25.446+05:30Access environment using ant<p>You can access environment variables within Ant using:</p> <pre><span style="font-size:130%;"><span style="font-weight: bold; color: rgb(255, 0, 0);"><br /></span><span style="color: rgb(255, 0, 0); font-weight: bold;"><</span><span style="font-weight: bold; color: rgb(255, 0, 0);">property environment="env"></span><br /><br /></span><br /></pre> <p>This provides all environment variables as Ant properties prefixed by "env.". For example, CLASSPATH would be accessible in Ant as ${env.CLASSPATH}. </p>Arunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com0tag:blogger.com,1999:blog-2703864537782412832.post-48115601720983243092007-07-19T16:10:00.000+05:302007-08-23T22:33:25.446+05:30Tomcat 5 Application Server Module Ant Codehttp://www.blogger.com/post-create.g?blogID=2703864537782412832Arunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com0tag:blogger.com,1999:blog-2703864537782412832.post-21785318764469191012007-07-18T19:31:00.000+05:302007-08-23T22:33:25.446+05:30ANT Heap Memory<p>Well a bit of Googling turned up that Ant looks for an environment variable called ANT_OPTS which is use to set Java parameters. Just set the environment variable and off you go. So I added the following to increase the heap size:</p> <pre><span style="color: rgb(255, 0, 0);font-size:130%;" ><span style="font-weight: bold;">export ANT_OPTS=-Xmx256m</span></span><br /> </pre> <p>That sets the maximum heap size to 256 Megabytes. It solved my problem as the XSLT transform topped out at about 220Meg. So if you ever need to increase the size of the Ant JVM, now you know how.</p>Arunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com3tag:blogger.com,1999:blog-2703864537782412832.post-87979137393241257662007-07-07T12:40:00.000+05:302007-08-23T22:33:25.446+05:30Java Report - Open Source & Free<span style="color: rgb(255, 0, 0);font-size:180%;" >Popular Java Report Generating Tool</span><br /><br />JasperReports is a powerful open source Java reporting tool that has the ability to deliver rich content onto the screen, to the printer or into PDF, HTML, XLS, CSV and XML files.<br /><br />It is entirely written in Java and can be used in a variety of Java enabled applications, including J2EE or Web applications, to generate dynamic content.<br /><br />Its main purpose is to help creating page oriented, ready to print documents in a simple and flexible manner.<br /><br /><span style="color: rgb(255, 0, 0);"> JasperReport Home</span> : <a href="http://jasperforge.org/sf/projects/jasperreports">http://jasperforge.org/sf/projects/jasperreports</a>Arunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com0tag:blogger.com,1999:blog-2703864537782412832.post-40262757104844474152007-07-06T17:35:00.000+05:302007-08-23T22:33:25.447+05:30J2EE MVC Frameworks (Open Source )Popular Frameworks<br /><br /><span style="color: rgb(51, 51, 255);">1. Spring Framework</span><br /><span style="color: rgb(51, 51, 255);">2. Struts Framework</span><br /><span style="color: rgb(51, 51, 255);">3. JavaServerFace (jsf)</span><br /><br /><span style="font-weight: bold; color: rgb(255, 0, 0);">Spring Framework</span><br /><p> Introducing Spring is harder than most frameworks because it's not a single-purpose technology. Spring can be thought of as a huge framework of best practices for almost every area of Java software development. Everything from Plain-Old-Java-Object (POJO) development, to web application development, to enterprise application development, to persistence layer management and aspect oriented programming (AOP). Spring supports it all and does so with some of the most well designed and heavily tested code in the Java industry. </p> <p> Because of its size, we need to focus this tutorial on the simplest application of Spring which is POJO development utilizing dependency injection. To clarify, dependency injection is a mechanism by which Spring handles creation and initializaton of the proper type of child object for a parent object at the moment the parent object needs the reference to the child. An example of where this is useful in the context of enterprise Java programming would be for your web application to instantly have access to your data-access layer in order to read or write an object from the database. This is a classic example of allowing Spring to inject the reference to the data-access layer into a POJO in the web application in order to load or save an object. </p> <p> To immediately demystify any all-knowing magic from your minds about this process, the way this is done in the Spring is that the object reference relationships are mapped out in XML configuration files in Spring 1.2 and handled with Java 5 annotations in Spring 2.0. <br /> </p> <p> Using this declarative method, Spring developers can actually soft-wire their application portions together using these annotations or XML configuration files such that when the application runs, Spring creates and instantiates all the object relationships "on demand". The advantage to having everything soft-wired is that portions of an application can quickly and easily be swapped out for alternative implementations (e.g. testing implementations) by simply changing around the annotations or XML configuration information and rerunning the application. There isn't even a need to recompile the application in some cases. This can be a huge boon to developers working on large applications that require constant testing or when delivering a larger application in interations. Spring provides a very natural way to thinking about these problems encouraging you to maintain your application in a modular architecture that supports this plugging and unplugging capability.<br /></p>Spring Home : <a href="http://www.springframework.org/">http://www.springframework.org/</a><br /><br /><span style="color: rgb(51, 51, 255);">Popular Tutorials</span><br /><a href="http://www.myeclipseide.com/images/tutorials/quickstarts/springintroduction/tutorial.html"><br />Tutorial Site -myeclipse</a><br /><a href="http://www.springframework.org/docs/MVC-step-by-step/Spring-MVC-step-by-step.html">Tutorial Site -SpringHome</a><br /><a href="http://www.roseindia.net/spring/index.shtml">Tutorial Site-Roseindia </a><br /><br /><br /><br /><span style="font-weight: bold; color: rgb(255, 0, 0);">Struts </span><br /><h2>What Is the Struts Framework?</h2> <p>The Struts Framework is a standard for developing well-architected Web applications. It has the following features: </p><ul><li>Open source</li><li>Based on the Model-View-Controller (MVC) design paradigm, distinctly separating all three levels: <ul><li><b>Model:</b> application state</li><li><b>View:</b> presentation of data (JSP, HTML)</li><li><b>Controller:</b> routing of the application flow</li></ul> </li><li>Implements the JSP Model 2 Architecture</li><li>Stores application routing information and request mapping in a single core file, <code>struts-config.xml</code></li></ul> The Struts Framework, itself, only fills in the View and Controller layers. The Model layer is left to the developer.<br /><br /><p class="MsoNormal" style="text-align: justify;"><span style=";font-family:Verdana;font-size:100%;" >Struts<i> </i>is a popular open source framework from Apache Software Foundation to build web applications that integrate with standard technologies such as Servlets, Java Beans and Java Server pages. </span></p> <p class="MsoNormal" style="text-align: justify;"><span style=";font-family:Verdana;font-size:100%;" >Struts offers many benefits to the web application developer,including the Model-View-Controller (MVC) design patterns (best practice) in web applications. </span></p> <p class="MsoNormal" style="text-align: justify;"><span style=";font-family:Verdana;font-size:100%;" >The Model-View-Controller paradigm applied to web applications lets you separately display code (for example, HTML and tag libraries) from flow control logic (action classes) from the data model to be displayed and updated by the application. </span></p> <p class="MsoNormal" style="text-align: justify;"><span style=";font-family:Verdana;font-size:100%;" >Struts offers a set of tag libraries to support the faster development of the different layers of the web application.</span></p> <p class="MsoNormal" style="text-align: justify;"><span style="font-size:100%;"> </span></p> <p class="MsoNormal" style="text-align: justify;"><span style=";font-family:Verdana;font-size:100%;" >The basic idea of the MVC architecture is to divide the application into three layers: Model that represents the data layer, a view layer that represents the data processed by the model component; and a Controller component that is responsible for interaction between the model and the controller. </span></p> <p class="MsoNormal" style="text-align: justify;"><span style=";font-family:Verdana;font-size:100%;" >So when we say Struts is an MVC framework for web based applications, we actually mean that it facilitates the rapid development of applications by providing a Controller that helps interaction between the model and the view so that an application developer has not to worry about how to make view and the model independent of each other and yet exist in coordination.</span></p><br />Struts Home <a href="http://struts.apache.org/">http://struts.apache.org</a><br /><br /><p>Popular Struts Tutorial<br /></p><p><a href="http://www.roseindia.net/struts/">Ttorial Site- Roseindia</a></p><p><a href="http://www.visualbuilder.com/jsp/struts/tutorial/">Ttorial Site-visualbuilder</a></p><p><a href="http://www.laliluna.de/first-steps-using-struts-tutorial.html">Ttorial Site-laliluna</a></p><p><a href="http://www.exadel.com/tutorial/struts/5.2/guess/strutsintro.html">Ttorial Site-exadel.</a></p><br /><p style="color: rgb(255, 0, 0);"><span style="font-weight: bold;">JSF</span></p><p>JavaServer Faces technology simplifies building user interfaces for JavaServer applications. Developers of various skill levels can quickly build web applications by: assembling reusable UI components in a page; connecting these components to an application data source; and wiring client-generated events to server-side event handlers.<br /><span style="font-weight: bold;"></span></p><h2>What Is JavaServer Faces?</h2><ul><li>Page navigation specification</li><li>Standard user interface components like input fields, buttons, and links </li><li>User input validation</li><li>Easy error handling</li><li>Java bean management</li><li>Event handling</li><li>Internationalization support</li></ul>JSF Home : <a href="http://java.sun.com/javaee/javaserverfaces/">http://java.sun.com/javaee/javaserverfaces/</a><a><br /><br /><span style="color: rgb(51, 51, 255);">Populat JSF Tutorials</span><br /></a><p><a href="http://www.exadel.com/tutorial/jsf/jsftutorial-kickstart.html">Ttorial Site-coreservlets.com</a></p><p><a href="http://www.exadel.com/tutorial/jsf/jsftutorial-kickstart.html">Ttorial Site-exadel</a><br /></p><p><a href="http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSFIntro.html">Ttorial Site-java.sun</a><br /></p><p><a href="http://www.jsftutorials.net/">Ttorial Site-jsftutorials</a><br /></p><p><a href="http://www.roseindia.net/jsf/">Ttorial Site-roseindia</a></p><p><br /></p><br /><p><br /></p><br /><p><br /></p><p><br /></p>Arunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com1tag:blogger.com,1999:blog-2703864537782412832.post-43316960866741976202007-06-23T17:55:00.000+05:302007-08-23T22:33:25.447+05:30java.OutOfMemoryException solutionOurJava Program is running under the<span class="on down" style="display: block;" id="formatbar_Transliterate" title="Write Hindi" onmouseover="ButtonHoverOn(this);" onmouseout="ButtonHoverOff(this);" onmouseup="" onmousedown="CheckFormatting(event);_TR_transliterate();;ButtonMouseDown(this);"></span>JVM, jvm is heart of the java,jvm is control the whole java program. jvm is allocating the memory space for every java instance . the default memory size is 64 mb . if any java instance exceed this size then Java.OutOfMemoryException will occurs .But we can change the default jvm size in runtime .<br /><br />if you want allocate 250 mb then<br /><br /> Syntax <span style="font-weight: bold;"> <span style="color: rgb(51, 51, 255);">java</span> -<span style="color: rgb(255, 0, 0);"><span style="color: rgb(51, 51, 255);">Xmx</span>250<span style="color: rgb(51, 102, 255);">m</span></span> <span style="color: rgb(51, 102, 255);">ClassFileName<br /><br /><br /><br />ex : java -Xmx500m -jar soundtracker.jar<br /> java </span></span><span style="font-weight: bold;"><span style="color: rgb(51, 102, 255);">-Xmx200m HelloWorld<br /></span></span>Arunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com0tag:blogger.com,1999:blog-2703864537782412832.post-7725132101675291032007-05-05T17:12:00.000+05:302007-08-23T22:27:13.063+05:30Mixing two audio files using Java SoundThere are no special methods in the Java Sound API to do this. However, mixing is a trivial signal processing task, it can be accomplished with plain Java code .<br />So manually mixing the two or more audioinputstreams using some attitional api<br />note: each Audiofile length must be same<br /><br />Download the Sample Sourcecode with API :<a href="http://www.live-share.com/files/218239/ais_mixer.rar.html"> Sample Source code ais_mixer.rar</a> <br />Alternate Downloading Mirror :<a href="http://javasoft.phpnet.us/src">mirror(ais_mixer.rar) </a><br /><br />or<br /><br /><br />Example:<br /><br />first convert audiofile to audioinputstream<br /><span style="color:blue;"><br />audioInputStream = AudioSystem.getAudioInputStream(soundFile);<br />audioInputStream2 = AudioSystem.getAudioInputStream(soundFile2);<br /></span><br />Create one collection list object using arraylist then add all audioinputstream's<br /><span style="color:blue;"><br /> Collection list=new ArrayList();<br /> list.add(audioInputStream2);<br /> list.add(audioInputStream);<br /></span><br />then pass the audioformat and collection list to MixingAudioInputStream constructor<br /><span style="color:blue;"><br /> MixingAudioInputStream mixer=new MixingAudioInputStream(audioFormat, list); <br /></span><br />finaly read data from mixed audioninputstream and give it to sourcedataline<br /><span style="color:blue;"><br /> nBytesRead =mixer.read(abData, 0,abData.length);<br /><br /> int nBytesWritten = line.write(abData, 0, nBytesRead);<br /></span>Arunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com5tag:blogger.com,1999:blog-2703864537782412832.post-6892905332405900002007-04-27T19:16:00.000+05:302007-08-23T22:30:41.705+05:30simple application for voice transmission and receiving using java rtp<h4 style="color: rgb(255, 0, 0);">Transmitter<br /></h4><span style="color:blue;">import javax.media.*;<br />import javax.media.control.*;<br />import javax.media.protocol.*;<br />import javax.media.format.*;<br /><br />import java.io.IOException;<br />import java.io.File;<br />import java.util.Vector;<br /><br /><br />public class MediaTransmitter {<br /><br /> private MediaLocator mediaLocator = null;<br /> private DataSink dataSink = null;<br /><br /> private Processor mediaProcessor = null;<br /> private static final Format[] FORMATS = new Format[] {<br /> new AudioFormat(AudioFormat.ULAW_RTP)};<br /> <br /> private static final ContentDescriptor CONTENT_DESCRIPTOR =<br /> new ContentDescriptor(ContentDescriptor.RAW_RTP);<br /><br /> public MediaTransmitter(MediaLocator locator) {<br /> mediaLocator = locator;<br /> }<br /><br /> public void startTransmitting() throws IOException {<br /> <br /> mediaProcessor.start(); <br /> dataSink.open();<br /> dataSink.start();<br /> }<br /><br /> public void stopTransmitting() throws IOException {<br /> <br /> dataSink.stop();<br /> dataSink.close(); <br /> mediaProcessor.stop();<br /> mediaProcessor.close();<br /> }<br /><br /> <br /> public void setDataSource(DataSource ds) throws IOException,<br /> NoProcessorException, CannotRealizeException, NoDataSinkException {<br /><br /> <br /> mediaProcessor = Manager.createRealizedProcessor(<br /> new ProcessorModel(ds, FORMATS, CONTENT_DESCRIPTOR));<br /><br /> <br /> dataSink = Manager.createDataSink(mediaProcessor.getDataOutput(),<br /> mediaLocator);<br /> }<br /> <br /> <br /> <br /> public static void main(String[] args) {<br /><br /> try {<br /> <br /> MediaLocator locator = new MediaLocator("rtp://192.168.1.111:333/audio");<br /> MediaTransmitter transmitter = new MediaTransmitter(locator);<br /> System.out.println("-> Created media locator: '" +<br /> locator + "'");<br /><br /> Vector devices=CaptureDeviceManager.getDeviceList ( null ); <br /> CaptureDeviceInfo cdi= (CaptureDeviceInfo) devices.elementAt ( 0 ); <br /> <br /> DataSource source = Manager.createDataSource(<br /> cdi.getLocator());<br /> <br /> transmitter.setDataSource(source);<br /> System.out.println("-> Set the data source on the transmitter"); <br /> <br /> transmitter.startTransmitting();<br /> System.out.println("-> Transmitting...");<br /> System.out.println(" Press the Enter key to exit");<br /><br /> System.in.read();<br /> System.out.println("-> Exiting");<br /> transmitter.stopTransmitting();<br /> <br /> } catch (Throwable t) {<br /> t.printStackTrace();<br /> }<br /><br /> System.exit(0);<br /> }<br />}<br /></span><br /><h4><br /><span style="color: rgb(255, 0, 0);">Receiver</span><br /></h4><span style="color:blue;">import javax.media.*;<br /><br />import java.io.File;<br />import java.io.IOException;<br />import java.net.URL;<br />import java.net.MalformedURLException;<br /><br />public class SimpleAudioPlayer {<br /><br /> <br /> private Player audioPlayer = null;<br /><br /> public SimpleAudioPlayer(MediaLocator url) throws IOException, NoPlayerException,<br /> CannotRealizeException {<br /> audioPlayer = Manager.createRealizedPlayer(url);<br /> }<br /><br /> public void play() {<br /> audioPlayer.start();<br /> }<br /><br /> <br /> public void stop() {<br /> audioPlayer.stop();<br /> audioPlayer.close();<br /> }<br /> public static void main(String[] args) {<br /> try {<br /> MediaLocator loc=new MediaLocator("rtp://192.168.1.111:333/audio"); <br /> SimpleAudioPlayer player = new SimpleAudioPlayer(loc);<br /> System.out.println(" Press the Enter key to exit");<br /> player.play(); <br /> System.in.read();<br /> System.out.println("-> Exiting");<br /> player.stop(); <br /> <br /> } catch (Exception ex) {<br /> ex.printStackTrace();<br /> }<br /><br /> System.exit(0);<br /> }<br />}<br /><br /><br /></span>Arunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com35tag:blogger.com,1999:blog-2703864537782412832.post-48981597571037097092007-04-18T19:51:00.000+05:302007-08-23T22:26:01.030+05:30SIP Intro<a href="http://developers.sun.com/solaris/articles/solaris_as_sip/solaris_as_sip.html"><br />http://developers.sun.com/solaris/articles/solaris_as_sip/solaris_as_sip.html</a>Arunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com0tag:blogger.com,1999:blog-2703864537782412832.post-34853855756422124792007-04-16T10:42:00.000+05:302007-08-23T22:26:01.031+05:30JMF Guid<A href="http://java.sun.com/products/java-media/jmf/1.0/guide/index.html">http://java.sun.com/products/java-media/jmf/1.0/guide/index.html</a>Arunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com0tag:blogger.com,1999:blog-2703864537782412832.post-23194780169421011222007-04-15T10:25:00.000+05:302007-08-23T22:33:25.447+05:30Java TV API Overview<p>The Java TV API is being designed to provide access to functionality unique to digital television receivers, including:</p> <ul><li>Audio/video streaming </li><li>Conditional access </li><li>Access to in-band and out-of-band data channels </li><li>Access to service information </li><li>Tuner control for channel changing </li><li>On-screen graphics control </li></ul>More :<a href="http://java.sun.com/products/javatv/">http://java.sun.com/products/javatv/</a>Arunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com0tag:blogger.com,1999:blog-2703864537782412832.post-6912136331753518542007-04-12T13:32:00.000+05:302007-08-23T22:26:01.031+05:30Sound over IP with jmf RTP<div class="post-body">This code will allow you to send and recive sound over IP network using RTP protocol.<br /><br /><span style="color:blue;"><br />import java.io.IOException;<br />import java.util.Vector;<br /><br />import javax.media.CaptureDeviceInfo;<br />import javax.media.CaptureDeviceManager;<br />import javax.media.DataSink;<br />import javax.media.Manager;<br />import javax.media.MediaLocator;<br />import javax.media.NoPlayerException;<br />import javax.media.NoProcessorException;<br />import javax.media.NotRealizedError;<br />import javax.media.Player;<br />import javax.media.Processor;<br />import javax.media.control.FormatControl;<br />import javax.media.control.TrackControl;<br />import javax.media.format.AudioFormat;<br />import javax.media.protocol.ContentDescriptor;<br />import javax.media.protocol.DataSource;<br /><br />public class SimpleVoiceTransmiter {<br /><br /> /**<br /> * @param args<br /> */<br /> public static void main(String[] args) {<br />// First find a capture device that will capture linear audio<br /> // data at 8bit 8Khz<br /> AudioFormat format= new AudioFormat(AudioFormat.LINEAR,<br /> 8000,<br /> 8,<br /> 1);<br /><br /> Vector devices= CaptureDeviceManager.getDeviceList( format);<br /><br /> CaptureDeviceInfo di= null;<br /><br /> if (devices.size() > 0) {<br /> di = (CaptureDeviceInfo) devices.elementAt( 0);<br /> }<br /> else {<br /> // exit if we could not find the relevant capturedevice.<br /> System.exit(-1);<br /> }<br /> <br /> // Create a processor for this capturedevice & exit if we<br /> // cannot create it<br /> Processor processor = null;<br /> try {<br /> processor = Manager.createProcessor(di.getLocator());<br /> } catch (IOException e) {<br /> System.exit(-1);<br /> } catch (NoProcessorException e) {<br /> System.exit(-1);<br /> }<br /><br /> // configure the processor <br /> processor.configure();<br /> <br /> while (processor.getState() != Processor.Configured){<br /> try {<br /> Thread.sleep(100);<br /> } catch (InterruptedException e) {<br /> // TODO Auto-generated catch block<br /> e.printStackTrace();<br /> }<br /> }<br /> <br /> processor.setContentDescriptor(<br /> new ContentDescriptor( ContentDescriptor.RAW));<br /> <br /> TrackControl track[] = processor.getTrackControls();<br /> <br /> boolean encodingOk = false;<br /> <br /> // Go through the tracks and try to program one of them to<br /> // output gsm data.<br /> <br /> for (int i = 0; i < track.length; i++) {<br /> if (!encodingOk && track[i] instanceof FormatControl) { <br /> if (((FormatControl)track[i]).<br /> setFormat( new AudioFormat(AudioFormat.GSM_RTP,<br /> 8000,<br /> 8,<br /> 1)) == null) {<br /><br /> track[i].setEnabled(false);<br /> }<br /> else {<br /> encodingOk = true;<br /> }<br /> } else {<br /> // we could not set this track to gsm, so disable it<br /> track[i].setEnabled(false);<br /> }<br /> }<br /> <br /> // At this point, we have determined where we can send out<br /> // gsm data or not.<br /> // realize the processor<br /> if (encodingOk) {<br /> processor.realize();<br /> while (processor.getState() != Processor.Realized){<br /> try {<br /> Thread.sleep(100);<br /> } catch (InterruptedException e) {<br /> // TODO Auto-generated catch block<br /> e.printStackTrace();<br /> }<br /> }<br /> // get the output datasource of the processor and exit<br /> // if we fail<br /> DataSource ds = null;<br /> <br /> try {<br /> ds = processor.getDataOutput();<br /> } catch (NotRealizedError e) {<br /> System.exit(-1);<br /> }<br /><br /> // hand this datasource to manager for creating an RTP<br /> // datasink our RTP datasink will multicast the audio<br /> try {<br /> String url= "rtp://224.0.0.1:22224/audio/16";<br /> <br /> MediaLocator m = new MediaLocator(url);<br /> <br /> DataSink d = Manager.createDataSink(ds, m);<br /> d.open();<br /> d.start();<br /> processor.start();<br /> } catch (Exception e) {<br /> System.exit(-1);<br /> } <br /> } <br /><br /><br /> <br /> }<br /><br />}<br /><br /><br /><br /><br />import java.io.IOException;<br />import java.net.MalformedURLException;<br /><br />import javax.media.Manager;<br />import javax.media.MediaLocator;<br />import javax.media.NoPlayerException;<br />import javax.media.Player;<br /><br />public class SimpleVoiceReciver{<br /><br /> /**<br /> * @param args<br /> */<br /> public static void main(String[] args) {<br /> String url= "rtp://192.168.1.111:22224/audio/16";<br /> <br /> MediaLocator mrl= new MediaLocator(url);<br /> <br /> if (mrl == null) {<br /> System.err.println("Can't build MRL for RTP");<br /> System.exit(-1);<br /> }<br /> <br /> // Create a player for this rtp session<br /> Player player = null;<br /> try {<br /> player = Manager.createPlayer(mrl);<br /> } catch (NoPlayerException e) {<br /> System.err.println("Error:" + e);<br /> System.exit(-1);<br /> } catch (MalformedURLException e) {<br /> System.err.println("Error:" + e);<br /> System.exit(-1);<br /> } catch (IOException e) {<br /> System.err.println("Error:" + e);<br /> System.exit(-1);<br /> }<br /> <br /> if (player != null) {<br /> System.out.println("Player created.");<br /> player.realize();<br />// wait for realizing<br /> while (player.getState() != Player.Realized){<br /> try {<br /> Thread.sleep(10);<br /> } catch (InterruptedException e) {<br /> e.printStackTrace();<br /> }<br /> }<br /> player.start();<br /> } else {<br /> System.err.println("Player doesn't created.");<br /> System.exit(-1);<br /> }<br /> }<br /><br />}<br /></span><br /></div>Arunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com4tag:blogger.com,1999:blog-2703864537782412832.post-49312449799066589552007-04-12T12:34:00.000+05:302007-08-23T22:27:13.063+05:30Record and Save Audio Using JavaStep 1:<br />First Read The Audio From MicroPhone<br /><br /><span style="color:blue;"> int cnt = targetDataLine.read( tempBuffer,0, tempBuffer.length);<br /><br /></span><br />Step 2:<br />Save data in output stream<br /><br /><span style="color:blue;"> byteArrayOutputStream.write(tempBuffer, 0, cnt);</span><br /><br />Step 3:<br />Get the saved data into a byte array object.<br /><br /><span style="color:blue;"> byte audioData[]=byteArrayOutputStream.toByteArray();</span><br /><br />Step 4:<br />Get an input stream on the byte array containing the data<br /><span style="color:blue;"><br />InputStream byteArrayInputStream = new ByteArrayInputStream(audioData);<br />AudioFormat audioFormat = getAudioFormat();<br />audioInputStream =new AudioInputStream(byteArrayInputStream,audioFormat,<br />audioData.length/audioFormat.getFrameSize());<br /><br /></span><br /><br />Step 5: Save To File<br /><span style="color:blue;"><br />if (AudioSystem.isFileTypeSupported(AudioFileFormat.Type.AU,<br /> audioInputStream)) {<br /> AudioSystem.write(audioInputStream, AudioFileFormat.Type.AU, file);<br />}<br /></span><span style="color:red;"><b><br />Note :If U want Full Source Code for This One then Download the Java File<a href="http://javasoft.phpnet.us/src/AudioRecorder.java"><br />http://javasoft.phpnet.us/src/AudioRecorder.java </a></b></span>Arunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.comtag:blogger.com,1999:blog-2703864537782412832.post-77105123787751196492007-04-12T10:35:00.000+05:302007-08-23T22:26:01.031+05:30RTP Using Java<b>Download Sample Application For RTP using Java<br /><a href="http://www.live-share.com/files/202962/rtpvoice.rar.html"><br />http://www.live-share.com/files/202962/rtpvoice.rar.html</a><br /><a href="http://www.live-share.com/files/202964/sam.zip.html"><br />http://www.live-share.com/files/202964/sam.zip.html</a><br /></b>Arunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com5tag:blogger.com,1999:blog-2703864537782412832.post-44534174509596060852007-04-09T11:20:00.000+05:302007-08-23T22:27:13.064+05:30Java Sound Capture And Save AU File Format and Convertionhttp://java.sun.com/docs/books/tutorial/sound/converters.htmlArunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com0tag:blogger.com,1999:blog-2703864537782412832.post-8138513367487231012007-04-05T18:04:00.000+05:302007-08-23T22:33:25.448+05:30SIP: Creating next-generation telecom applicationsSIP: Creating next-generation telecom applications<br /><br />The Session Initiation Protocol makes developing apps for telecommunications networks easier than ever<br />Download SipServlet api from <br />http://www-128.ibm.com/developerworks/library/wi-sip.html<br /><br /><br />SIP programming for the Java developer<br />Deliver SIP-based services to Java applications with SIP Servlet<br />Download sample application src<br /><br />http://www.javaworld.com/javaworld/jw-06-2006/jw-0619-sip.html?page=1Arunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com0tag:blogger.com,1999:blog-2703864537782412832.post-32107139509320283622007-04-05T15:03:00.000+05:302007-08-23T22:32:04.247+05:30SSL VS Tomcat Step by Step Configuration1 . Certificate Generation<br /><br />Create a certificate keystore by executing the following command<br /><br /><font color=red><br /># keytool -genkey -alias tomcat -keyalg RSA<br /><br /></font><br />and specify a password value of "changeit".<br /><br /><br />2 . Tomcat Configuration<br /><br />open the server.xml file from tomcat_home /conf directory and uncommit or add the following configurations<br /><font color=red><br /><-- Define an SSL HTTP/1.1 Connector on port 8443 --><br /><br /><connector classname="org.apache.catalina.connector.http.HttpConnector" port="8443" minprocessors="5" maxprocessors="75" enablelookups="true" acceptcount="10" debug="0" scheme="https" secure="true" clientauth="false" protocol="TLS"><br /></font><br /><br />next start the server and try <font color=red>https://localhost:8443/ </font>url . you should see the usual Tomcat splash pageArunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com0tag:blogger.com,1999:blog-2703864537782412832.post-34806445358369530842007-04-05T14:59:00.000+05:302007-08-23T22:31:18.739+05:30mysql Couldn't find the mysql server or managerSolution <br />Step 1.)<br /><br />Rem out the line in /etc/my.conf that was setting basedir to /var/lib. As seen below:<br /><strong><font color=red><br />user=mysql<br />#basedir=/var/lib<br /></font></strong><br />Step 2.)<br /><br />Create the directory "/var/run/mysqld" if it does not exist. Then chown that directory to mysql.mysql as below...<br /><strong><font color=red><br />mkdir /var/run/mysqld<br />chown mysql.mysql /var/run/mysqld<br /></font></strong><br />Step 3.)<br /><br />Start the service..<br /><strong><font color=red><br />service mysql start<br /></font></strong>Arunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com37tag:blogger.com,1999:blog-2703864537782412832.post-4719964372593824612007-04-05T14:55:00.000+05:302007-04-05T14:58:43.768+05:30Download files using Servlet<font color=blue><br />String fileName = "db.zip";<br />res.setContentType("application/octet-stream");<br />res.setHeader("Content-Disposition","attachment; filename=\"" + fileName + "\"");<br />OutputStream oStream = res.getOutputStream();<br />FileInputStream file=new FileInputStream("c:\\db.zip");<br /><br />String sOutput ="Arunkumar";/*what ever be the information you want to download, should be specified here.*/<br />int i=0;<br />while((i=file.read())!=-1){<br />oStream.write(i);}<br />file.close();<br />oStream.close();<br /></font>Arunhttp://www.blogger.com/profile/11417982725600476140noreply@blogger.com5