tag:blogger.com,1999:blog-16865398972754185132024-02-08T03:58:41.985-08:00Opening My SkullGovindaramhttp://www.blogger.com/profile/17002710620415708562noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-1686539897275418513.post-1371345615611128982022-05-12T01:36:00.003-07:002022-05-12T02:05:42.284-07:00Maven plugin configuration without editing POM xml<p> <span style="font-family: georgia;">Usually maven plug-ins are configured by modifying the POM xml file. For example, in the following configuration POM file is edited to set the expected source and target for the maven-compiler-plugin</span></p><p><span class="hljs-tag" style="box-sizing: border-box; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;"><<span class="hljs-name" style="box-sizing: border-box; color: #63b175; font-weight: 600;">plugin</span>></span><span style="background-color: #fafafa; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;">
</span><span class="hljs-tag" style="box-sizing: border-box; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;"><<span class="hljs-name" style="box-sizing: border-box; color: #63b175; font-weight: 600;">artifactId</span>></span><span style="background-color: #fafafa; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;">maven-compiler-plugin</span><span class="hljs-tag" style="box-sizing: border-box; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;"></<span class="hljs-name" style="box-sizing: border-box; color: #63b175; font-weight: 600;">artifactId</span>></span><span style="background-color: #fafafa; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;">
</span><span class="hljs-tag" style="box-sizing: border-box; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;"><<span class="hljs-name" style="box-sizing: border-box; color: #63b175; font-weight: 600;">version</span>></span><span style="background-color: #fafafa; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;">3.7.0</span><span class="hljs-tag" style="box-sizing: border-box; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;"></<span class="hljs-name" style="box-sizing: border-box; color: #63b175; font-weight: 600;">version</span>></span><span style="background-color: #fafafa; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;">
</span><span class="hljs-tag" style="box-sizing: border-box; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;"><<span class="hljs-name" style="box-sizing: border-box; color: #63b175; font-weight: 600;">configuration</span>></span><span style="background-color: #fafafa; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;">
</span><span style="background-color: #fafafa; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;"> </span><span class="hljs-tag" style="box-sizing: border-box; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;"><<span class="hljs-name" style="box-sizing: border-box; color: #63b175; font-weight: 600;">source</span>></span><span style="background-color: #fafafa; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;">1.8</span><span class="hljs-tag" style="box-sizing: border-box; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;"></<span class="hljs-name" style="box-sizing: border-box; color: #63b175; font-weight: 600;">source</span>></span><span style="background-color: #fafafa; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;">
</span><span class="hljs-tag" style="box-sizing: border-box; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;"><<span class="hljs-name" style="box-sizing: border-box; color: #63b175; font-weight: 600;">target</span>></span><span style="background-color: #fafafa; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;">1.8</span><span class="hljs-tag" style="box-sizing: border-box; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;"></<span class="hljs-name" style="box-sizing: border-box; color: #63b175; font-weight: 600;">target</span>></span><span style="background-color: #fafafa; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;">
</span><span class="hljs-tag" style="box-sizing: border-box; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;"></<span class="hljs-name" style="box-sizing: border-box; color: #63b175; font-weight: 600;">configuration</span>></span><span style="background-color: #fafafa; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;">
</span><span class="hljs-tag" style="box-sizing: border-box; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;"></<span class="hljs-name" style="box-sizing: border-box; color: #63b175; font-weight: 600;">plugin</span>></span></p><p><span class="hljs-tag" style="box-sizing: border-box; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; white-space: pre-wrap;"><br /></span></p><p><span style="font-size: 14px; white-space: pre-wrap;"><span style="font-family: georgia;">In some scenario, we may not have option to modify the POM file. In those conditions, we can configure the plugin by adding the configuration in the command line. For example, in the command below the maven-compiler-plugin is configured using command line arguments without modifying the POM file. </span></span></p><p><span class="hljs-name" style="box-sizing: border-box; color: #63b175; font-family: "Source Code Pro", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14px; font-weight: 600; white-space: pre-wrap;">mvn install -Dmaven.compiler.source=1.7 -Dmaven.compiler.target=1.7</span></p><p><br /></p><p>Note: The configuration set in the command line is not same as in the POM file. We should set User property in the command line. The User property should be available in the plugin documentation. For example, https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html</p><p><br /></p>Govindaramhttp://www.blogger.com/profile/17002710620415708562noreply@blogger.com0tag:blogger.com,1999:blog-1686539897275418513.post-76564664092602692442022-02-11T05:32:00.004-08:002022-05-12T02:02:52.283-07:00Clean code - Optional comparisonFollowing is an example of writing less verbose and clean code for optional value comparison.
This code (isAbc2) avoids unnecessary IF condition.
The code sample also has a way to compare clean code and legacy code for a safety.
<pre style="background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; overflow-wrap: normal; word-wrap: normal;">
import java.util.Optional;
public class C1 {
public static void main(String[] arg) {
Optional<String> val = Optional.of("abc");
Optional<String> noval = Optional.empty();
Optional<String> def = Optional.of("def");
System.out.println(isAbc1(val) == isAbc2(val));
System.out.println(isAbc1(noval) == isAbc2(noval));
System.out.println(isAbc1(def) == isAbc2(def));
}
private static boolean isAbc1(Optional<String> op) {
if(op.isPresent()) {
return op.get().equals("abc");
}
return false;
}
// clean code
private static boolean isAbc2(Optional<String> op) {
return op.map("abc"::equals).orElse(false);
}
}
</code></pre>
The result of the above code in JDK 11.
<pre>
<code>
true
true
true
</code>
</pre>Govindaramhttp://www.blogger.com/profile/17002710620415708562noreply@blogger.com0tag:blogger.com,1999:blog-1686539897275418513.post-55783174548962486262021-02-11T04:59:00.002-08:002022-05-12T02:03:10.671-07:00Compact code with flatMap for methods returning Optional<div dir="ltr" style="text-align: left;" trbidi="on">
Compact code with flatMap for methods returning Optional. flatMap() method is available both in Stream and Optional. flatMap method can help in writing compact code as shown below. Moreover several article suggest to avoid using get() in Optional. flatMap() can also help in avoiding get() as shown below. <br />
<br />
<pre style="background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; overflow-wrap: normal; word-wrap: normal;">
import java.util.List;
import java.util.Optional;
public class OpMap {
public static void main(String[] arg) {
Emp emp = new Emp();
String dname = emp.getDept()
.map(Dept::getName)
.orElse("temp");
System.out.println(dname);
dname = emp.getDept()
.map(Dept::getOptionalName)
.orElse(Optional.empty()) // This is bad
.orElse("temp");
System.out.println(dname);
dname = emp.getDept()
.map(Dept::getOptionalName)
.filter(Optional::isPresent) // This is bad
.map(Optional::get) // This is bad
.orElse("temp");
System.out.println(dname);
dname = emp.getDept()
.flatMap(Dept::getOptionalName) // Better option
.orElse("temp");
System.out.println(dname);
List<Emp> emps = List.of(new Emp());
dname = emps.stream()
.map(Emp::getDept)
.filter(Optional::isPresent) // This is bad
.map(Optional::get) // This is bad
.map(Dept::getOptionalName)
.filter(Optional::isPresent) // This is bad
.map(Optional::get) // This is bad
.findFirst().orElse("temp");
System.out.println(dname);
dname = emps.stream()
.map(Emp::getDept)
.flatMap(Optional::stream) // Better option
.map(Dept::getOptionalName)
.flatMap(Optional::stream) // Better option
.findFirst().orElse("temp");
System.out.println(dname);
}
static class Emp {
private String eName;
private Dept dept;
public Optional<String> geteName() {
return Optional.ofNullable(eName);
}
public void seteName(String eName) {
this.eName = eName;
}
public Optional<Dept> getDept() {
return Optional.ofNullable(dept);
}
public void setDept(Dept dept) {
this.dept = dept;
}
}
static class Dept {
private String dName;
public String getName() {
return dName;
}
public Optional<String> getOptionalName() {
return Optional.ofNullable(dName);
}
public void setdName(String dName) {
this.dName = dName;
}
}
}
</code></pre>
<br /></div>Govindaramhttp://www.blogger.com/profile/17002710620415708562noreply@blogger.com0tag:blogger.com,1999:blog-1686539897275418513.post-11580051909995043692018-02-21T23:26:00.003-08:002018-02-21T23:27:24.215-08:00Git add, commit and push in single command<div dir="ltr" style="text-align: left;" trbidi="on">
We can replace frequently used multiple git commands like add, commit and push in a single command.<br />
<br />
Multiple step Git add, commit, push<br />
<br />
<pre>git add .
git commit -m "message"
git push
</pre>
<br />
Single step Git add, commit and push<br />
<pre>git commit -am "message" && git push
</pre>
<br /></div>
Govindaramhttp://www.blogger.com/profile/17002710620415708562noreply@blogger.com0tag:blogger.com,1999:blog-1686539897275418513.post-36243145405858073912017-11-19T09:04:00.001-08:002017-11-19T09:06:18.447-08:00Serialize & Deserialize exactly same as JAX-RS server<div dir="ltr" style="text-align: left;" trbidi="on">
The following code sample show a way to serialize and deserialize exactly same as the JAX-RS server. The code used the same <span style="background-color: #f0f0f0; font-family: "arial"; font-size: 12px;">MessageBodyReader</span> and <span style="background-color: #f0f0f0; font-family: "arial"; font-size: 12px;">MessageBodyWriter</span> used while Jersey frameworks converts request and response body.<br />
<br />
The annotation <span style="background-color: #f0f0f0; font-family: "arial"; font-size: 12px;">javax.ws.rs.core.Context</span> is the key. The Providers used by the framework can be fetched from the context.<br />
<br />
I have used this technique to improve the performance of the GET call. There are no serialization and deserialization during the GET call. It helps in improving the performance<br />
<br />
<br />
<pre style="background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: "arial"; font-size: 12px; height: auto; line-height: 20px; overflow: auto; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.ext.MessageBodyReader;
import javax.ws.rs.ext.MessageBodyWriter;
import org.springframework.stereotype.Component;
@Path("/emp")
@Produces({ MediaType.APPLICATION_JSON })
@Component
public class EmpResource {
@Context
javax.ws.rs.ext.Providers providers;
@POST
public Employee post(Employee emp) {
//convert POJO to String
MessageBodyWriter<employee> writer = providers.getMessageBodyWriter(Employee.class,
Employee.class, null, MediaType.APPLICATION_JSON_TYPE);
String jsonString = null;
try {
ByteArrayOutputStream entityStream = new ByteArrayOutputStream();
writer.writeTo(emp, Employee.class, Employee.class, null,
MediaType.APPLICATION_JSON_TYPE, null, entityStream);
jsonString = entityStream.toString();
// Business logic
//Store jsonString to back end
} catch (IOException e) {}
//convert String to POJO
MessageBodyReader<employee> reader = providers.getMessageBodyReader(Employee.class,
Employee.class, null, MediaType.APPLICATION_JSON_TYPE);
Employee emp2 = null;
try {
emp2 = reader.readFrom(Employee.class, Employee.class, null,
MediaType.APPLICATION_JSON_TYPE, null,
new ByteArrayInputStream(jsonString.getBytes()));
} catch (Exception e) {}
return emp2;
}
@GET
public String get(@QueryParam("id") String id) {
//Read from backend
String jsonString = null;
//Performance improvement: Avoiding String-POJO-String conversion
return jsonString;
}
}
</employee></employee></code></pre>
<br />
<br />
<br /></div>
Govindaramhttp://www.blogger.com/profile/17002710620415708562noreply@blogger.com0tag:blogger.com,1999:blog-1686539897275418513.post-80994141980558263312017-08-20T07:12:00.000-07:002017-08-20T07:12:50.791-07:00Java stream: Logging before filter<div dir="ltr" style="text-align: left;" trbidi="on">
While iterating in Java Streams, we may need to log all the items processed by the stream. Especially when using filter in the stream. We can use Peek api for achieving the same.<br />
<br />
The following ready to run code will help try out.<br />
<pre style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;">
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class LogStream {
public static void main(String[] args) {
System.out.println("Log");
List<Emp> result = data().stream()
.peek(e -> System.out.println(e.getSalary()))
.filter(e -> e.getSalary()
.doubleValue() < 2)
.collect(Collectors.toList());
System.out.println("Result");
result.forEach(e -> System.out.println(e.getSalary()));
}
static class Emp {
public Emp(String name, String dept, BigDecimal salary) {
super();
this.name = name;
this.dept = dept;
this.salary = salary;
}
private String name;
private String dept;
private BigDecimal salary;
public String getName() {
return name;
}
public String getDept() {
return dept;
}
public BigDecimal getSalary() {
return salary;
}
}
private static List<Emp> data() {
Emp e1 = new Emp("e1", "dept1", BigDecimal.valueOf(1.1));
Emp e2 = new Emp("e2", "dept1", BigDecimal.valueOf(1.1));
Emp e3 = new Emp("e3", "dept2", BigDecimal.valueOf(2.1));
Emp e4 = new Emp("e4", "dept2", BigDecimal.valueOf(1.9));
return Arrays.asList(e1, e2, e3, e4);
}
}
</code></pre>
<br /></div>
Govindaramhttp://www.blogger.com/profile/17002710620415708562noreply@blogger.com1tag:blogger.com,1999:blog-1686539897275418513.post-17074622358782813632017-02-20T08:18:00.001-08:002022-05-18T23:38:09.831-07:00Java 8 stream - GroupingBy sum BigDecimal - summarizingBigDecimal<div dir="ltr" style="text-align: left;" trbidi="on">
Java 8 stream - GroupingBy and summing a BigDecimal field<br />
<br />
<pre style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;"> import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class C1 {
public static void main(String[] arg){
Map<String, BigDecimal> result = data().stream()
<b><i>.collect(Collectors.groupingBy(Emp::getDept,
Collectors.mapping(Emp::getSalary, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));</i> </b>
System.out.println(result);
}
static class Emp{
public Emp(String name, String dept, BigDecimal salary) {
super();
this.name = name;
this.dept = dept;
this.salary = salary;
}
private String name;
private String dept;
private BigDecimal salary;
public String getName() {
return name;
}
public String getDept() {
return dept;
}
public BigDecimal getSalary() {
return salary;
}
}
private static List<Emp> data(){
Emp e1 = new Emp("e1", "dept1", BigDecimal.valueOf(1.1));
Emp e2 = new Emp("e2", "dept1", BigDecimal.valueOf(1.1));
Emp e3 = new Emp("e3", "dept2", BigDecimal.valueOf(2.1));
Emp e4 = new Emp("e4", "dept2", BigDecimal.valueOf(1.9));
return Arrays.asList(e1, e2, e3, e4);
}
}
</code></pre>
<br />
If Salary is Integer or Long or Double, Collectors class provides direct method for summing. Eg: summarizingInt, summarizingLong, summarizingDouble. Always prefer to use methods from JDK instead of writing your own code.
</div>
Govindaramhttp://www.blogger.com/profile/17002710620415708562noreply@blogger.com2tag:blogger.com,1999:blog-1686539897275418513.post-91440689119127135512016-02-06T03:59:00.002-08:002016-02-06T04:01:50.763-08:00Get EC2 tag key-value in Java<div dir="ltr" style="text-align: left;" trbidi="on">
The following code snippet is a sample for retrieving AWS EC2 instance's tags in a Java program.<br />
<br />
<pre>import java.util.Collection;
import java.util.LinkedList;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.ec2.AmazonEC2Client;
import com.amazonaws.services.ec2.model.DescribeTagsRequest;
import com.amazonaws.services.ec2.model.DescribeTagsResult;
import com.amazonaws.services.ec2.model.Filter;
import com.amazonaws.services.ec2.model.TagDescription;
import com.amazonaws.util.EC2MetadataUtils;
public class GetTag{
public static void main(String[] args){
DescribeTagsRequest req = new DescribeTagsRequest();
Collection<filter> filters = new LinkedList<>();
LinkedList<string> instanceList = new LinkedList<>();
//Get instanceId of the current instance
String instanceId = EC2MetadataUtils.getInstanceId();
instanceList.add(instanceId);
Filter filter = new Filter("resource-id", instanceList);
filters.add(filter);
req.setFilters(filters);
AmazonEC2Client client = new AmazonEC2Client();
client.setRegion(Region.getRegion(Regions.US_WEST_2));
DescribeTagsResult tagResult = client.describeTags(req);
if(tagResult != null){
for(TagDescription tag:tagResult.getTags()){
System.out.println(tag.getKey());
System.out.println(tag.getValue());
}
}
}
}
</string></filter></pre>
<br /></div>
Govindaramhttp://www.blogger.com/profile/17002710620415708562noreply@blogger.com0tag:blogger.com,1999:blog-1686539897275418513.post-63720790190570236452015-02-09T03:52:00.000-08:002015-05-25T22:48:48.030-07:00Perforce eclipse error: Error occurred during the SSL handshake: invalid SSL session<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
How to fix the eclipse's perforce plugin error "Error occurred during the SSL handshake: invalid SSL session"</h2>
<div>
<br /></div>
<div>
If you are getting the above error, it means your JVM and Perforce servers are not successfully exchanging SSL certificate. You have install JCE (Java Cryptography Extension) to make it work.</div>
<div>
<br /></div>
<div>
These are the steps to fix this issue:</div>
<h3 style="text-align: left;">
Download JCE</h3>
<div>
<br /></div>
<div>
Link for Java 6 <a href="http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html" target="_blank">http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html</a></div>
<div>
Link for Java 7 <a href="http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html" target="_blank">http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html</a></div>
<div>
Link for Java 8 <a href="http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html" target="_blank">http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html</a></div>
<div>
<br /></div>
<div>
If the above didn't work, search with the keywords "JCE Java 6" or "JCE Java 7" or "JCE Java 8" depending on the Java version you are using.</div>
<div>
<br /></div>
<h3 style="text-align: left;">
Backup existing libraries</h3>
<div>
<br /></div>
<div>
Backup the following libraries available under the location "<span style="background-color: white; color: #444444; font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18.2000007629395px;">$JAVA_HOME/jre/lib/security</span>" to a safe location. You have to overwritten these libraries in next step.</div>
<div>
<ul style="text-align: left;">
<li><span style="background-color: white; color: #444444; font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18.2000007629395px;">local_policy.jar</span></li>
<li><span style="background-color: white; color: #444444; font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18.2000007629395px;"><span style="line-height: 18.2000007629395px;">US_export_policy.jar</span></span></li>
</ul>
<h3 style="text-align: left;">
Copy libraries</h3>
</div>
<div>
The JCE package downloaded in step one would have two jars (local_policy.jar, US_export_policy.jar). Extract these two files to the location "<span style="background-color: white; color: #444444; font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 18.2000007629395px;">$JAVA_HOME/jre/lib/security</span>"</div>
<div>
<br /></div>
<h3 style="text-align: left;">
Restart Eclipse</h3>
<div>
Close your eclipse if it is already running. After restarting the eclipse, you should be able to successfully connect to perforce.</div>
<div>
<br /></div>
</div>
Govindaramhttp://www.blogger.com/profile/17002710620415708562noreply@blogger.com0tag:blogger.com,1999:blog-1686539897275418513.post-81750420990366784152010-08-18T02:33:00.000-07:002010-08-18T02:45:07.918-07:00Arrange Number - Blackberry game<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_agaGYGvCtZ0/TGurHm0e2_I/AAAAAAAAB5U/XK4ghcMTlGM/s1600/num.PNG"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 13px; height: 19px;" src="http://2.bp.blogspot.com/_agaGYGvCtZ0/TGurHm0e2_I/AAAAAAAAB5U/XK4ghcMTlGM/s320/num.PNG" border="0" alt="" id="BLOGGER_PHOTO_ID_5506683116558670834" /></a>I created my first Blackberry application. It is a simple puzzle game. Objective of the game is to arrange numbers in order by moving the numbers over one empty space available.<div>The application is available at <a href="http://www.rimgear.com/en/eur/device:BlackBerry_8230+Pearl+Flip/Arrange-Number/product_6217961_details.html">http://www.rimgear.com/en/eur/device:BlackBerry_8230+Pearl+Flip/Arrange-Number/product_6217961_details.html</a> </div><div><br /></div><div>It runs all the device with Blackberry OS 4.6. It works very well in my Blackberry pearl flip.</div><div>Blackberry user please try this out. </div><div><br /></div><div><br /></div><div><br /></div>Govindaramhttp://www.blogger.com/profile/17002710620415708562noreply@blogger.com0tag:blogger.com,1999:blog-1686539897275418513.post-75578699220415035372010-05-16T23:21:00.000-07:002010-05-16T23:30:23.252-07:00Deleting all data of a site in FirefoxThe latest version of FireFox has good feature which suggest the URLs from your history as you type. But it would be annoying if suggest list the site you are not interested on.<div><br /></div><div>To delete those sites from history. </div><div>1. Goto Menu History > Show all history (or) ctrl+shift+H </div><div>2. Select the site you can to delete by searching (or) browsing through the history.</div><div>3. Right click and say 'Forget about this site'</div><div><br /></div><div>It will delete all the history of the selected site. </div>Govindaramhttp://www.blogger.com/profile/17002710620415708562noreply@blogger.com0tag:blogger.com,1999:blog-1686539897275418513.post-60920895792392119582009-10-27T07:17:00.000-07:002012-12-20T06:12:45.806-08:00Memory Calculator<div dir="ltr" style="text-align: left;" trbidi="on">
I have created a utility to calculated the size of memory occupied by different scope variable in ColdFusion.<br />
I have submitted the same in Adobe Cookbooks. It is available at <a href="http://cookbooks.adobe.com/post_Memory_Calculator-16384.html">Memory Calculator</a> <br />
<br />
Have a look at it and provide your comments/suggestion/rating.</div>
Govindaramhttp://www.blogger.com/profile/17002710620415708562noreply@blogger.com0tag:blogger.com,1999:blog-1686539897275418513.post-86507964932200938772008-10-14T21:47:00.000-07:002008-10-14T22:20:04.214-07:00Coldfusion debugger common mistake<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_agaGYGvCtZ0/SPV74-jL2mI/AAAAAAAABps/Rn43EixQSH4/s1600-h/cfdebug.JPG"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://2.bp.blogspot.com/_agaGYGvCtZ0/SPV74-jL2mI/AAAAAAAABps/Rn43EixQSH4/s320/cfdebug.JPG" alt="" id="BLOGGER_PHOTO_ID_5257244358818388578" border="0" /></a><br />Step-through debugging is the best method of debugging I ever know. With the introduction of ColdFusion Step-through debugger as eclipse plug-in, coldfusion development became much handy. But I have noticed most of them do a simple careless mistake while setting up the debugger for the first time (including me). Just thought of mentioning it here.<br /><br />In the RDS configuration under ColdFusion preference, the value of the port number should be the <span style="font-weight:bold;">http port number</span> of the ColdFusion server. But as a continuation of server side debugger setup, people used to enter the debugger port specified in the ColdFusion administer.<br /><br />It would be better if Adobe includes some description for the Port Number field as it does for the Context Root fieldGovindaramhttp://www.blogger.com/profile/17002710620415708562noreply@blogger.com0tag:blogger.com,1999:blog-1686539897275418513.post-36129450851732796102008-07-09T08:11:00.000-07:002008-07-10T06:22:58.570-07:00Coldfusion CustomTag for Query batch processingI have created my first coldfusion custom tag. The purpose of this tag to open the query batch processing feature provided by JDBC to the coldfusion developer. It is just build over the JDBC prepared statement. I tried to make it as close as regular coldfusion tags, so that their won't be much confusion in using the tag.<br />The sample code to use the custom tag is shown below:<br /><br /><pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"><code><cf_preparedstmt datasource="webrequest" query="insert into Employee(id, name) values(?,?)"><br /><cf_batch><br /> <cf_batchparam position="1" value="26" type="INT"><br /> <cf_batchparam position="2" value="name1" type="STRING"><br /></cf_batch><br /><cf_batch><br /> <cf_batchparam position="1" value="27" type="INT"><br /> <cf_batchparam position="2" value="name2" type="STRING"><br /></cf_batch><br /><br /></cf_preparedstmt><br /></code></pre><br /><br />The usage of this tag is almost similar to cfquery or cfstoredproc.<br /><br />The source code for all the three tags are available here.<br /><br />1. cf_preparedstmt:<br /><pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"><code><cfif thisTag.ExecutionMode is 'start'><br /><br /><!--- Arribute validation ---><br /><cfif not StructKeyExists(Attributes, "datasource") or len(Attributes.datasource) eq 0><br /> <cfthrow message="Attribute datasource missing in cf_preparedstmt tag"><br /></cfif> <br /><cfif not StructKeyExists(Attributes, "query") or len(Attributes.query) eq 0><br /> <cfthrow message="Attribute query missing in cf_preparedstmt tag"><br /></cfif><br /> <cfif StructKeyExists(Request, 'preparedstatement') and len(Request.preparedstatement)><br /> <cfthrow message="Nesting cf_preparedstmt tag is not allowed"><br /> </cfif><br /><br /><!--- Create Connection and PreparedStatment ---><br /> <cfscript><br /> factory = createObject("java", "coldfusion.server.ServiceFactory");<br /> connection = factory.getDataSourceService().getDataSource(Attributes.datasource).getConnection();<br /> Request.preparedstatement = connection.prepareStatement(Attributes.query);<br /></cfscript> <br /><br /><cfelseif thisTag.ExecutionMode is 'end'><br /><br /> <!--- Execute and close the resource ---><br /><cfscript><br /> Request.preparedstatement.executeBatch();<br /> Request.preparedstatement.close();<br /> Request.preparedstatement = "";<br /></cfscript><br /><br /></cfif><br /></code></pre><br /><br />2. cf_batch:<br /><pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"><code><cfif thisTag.ExecutionMode is 'start'><br /> <cfif not StructKeyExists(Request, 'preparedstatement')><br /> <cfthrow message="cf_batchparam tag should be used inside cf_prepatedstmt tag"><br /> </cfif><br /><br /><cfelseif thisTag.ExecutionMode is 'end'><br /> <cfscript><br /> Request.preparedstatement.addBatch();<br /></cfscript><br /></cfif><br /></code></pre><br /><br />3. cf_batchparam<br /><pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"><code><cfif thisTag.ExecutionMode is 'start'><br /><br /><!--- Arribute validation ---><br /><cfif not StructKeyExists(Attributes, 'position') or not IsNumeric(Attributes.position)><br /> <cfthrow message="Attribute position should be numeric"><br /></cfif> <br /><cfif not StructKeyExists(Attributes, 'value')><br /> <cfthrow message="The Required Attribute value is undefined"><br /></cfif><br /> <cfif not StructKeyExists(Request, 'preparedstatement')><br /> <cfthrow message="cf_batchparam tag should be used inside cf_prepatedstmt tag"><br /> </cfif><br /><br /> <!--- set values ---><br /> <cfswitch expression="#Attributes.type#"><br /> <cfcase value="BOOLEAN"><br /> <cfset Request.preparedstatement.setBoolean(Attributes.position, Attributes.value)><br /> </cfcase><br /> <cfcase value="BYTE"><br /> <cfset Request.preparedstatement.setByte(Attributes.position, Attributes.value)><br /> </cfcase><br /> <cfcase value="SHORT"><br /> <cfset Request.preparedstatement.setShort(Attributes.position, Attributes.value)><br /> </cfcase><br /> <cfcase value="INT"><br /> <cfset Request.preparedstatement.setInt(Attributes.position, Attributes.value)><br /> </cfcase><br /> <cfcase value="LONG"><br /> <cfset Request.preparedstatement.setLong(Attributes.position, Attributes.value)><br /> </cfcase><br /> <cfcase value="FLOAT"><br /> <cfset Request.preparedstatement.setFloat(Attributes.position, Attributes.value)><br /> </cfcase><br /> <cfcase value="DOUBLE"><br /> <cfset Request.preparedstatement.setDouble(Attributes.position, Attributes.value)><br /> </cfcase><br /> <cfcase value="BIGDECIMAL"><br /> <cfset Request.preparedstatement.setBigDecimal(Attributes.position, Attributes.value)><br /> </cfcase><br /> <cfcase value="STRING"><br /> <cfset Request.preparedstatement.setString(Attributes.position, Attributes.value)><br /> </cfcase><br /> <cfdefaultcase><br /> <cfthrow message="The Required Attribute type is undefined"><br /> </cfdefaultcase><br /> </cfswitch> <br /></cfif><br /></code></pre><br /><br /><br />To make use of these tags save the source code in the file preparedstmt.cfm, batch.cfm, batchparam.cfm respectively and place it under the customtags folder specified in the coldfusion administrator.<br /><br />Please provide your comments.Govindaramhttp://www.blogger.com/profile/17002710620415708562noreply@blogger.com1tag:blogger.com,1999:blog-1686539897275418513.post-1374832880699363832008-06-30T23:10:00.000-07:002008-06-30T23:18:10.675-07:00CfEclipse 1.3.2 availableGood news for coldfusion developers who love eclipse.<br />Cfeclipse 1.3.2 is available now. Ofcourse it is beta :-)<br /><br /><br />This url give you a complete list of fixes and enhancement available in 1.3.2<br />http://trac.cfeclipse.org/cfeclipse/query?status=closed&group=resolution&milestone=1.3.2<br /><br />Try this out.Govindaramhttp://www.blogger.com/profile/17002710620415708562noreply@blogger.com0