Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Monday, August 29, 2016

Very BigInteger

java.lang.BigInteger is very helpful but I think we should use this class with correct implementation.
If you use this class for keeping Integer values and convert them  into int type you need checking the returned value if it is too big for integer. According to specification,  soft warning is shown but many developers omit this information mostly.


intValue

public int intValue()
Converts this BigInteger to an int. This conversion is analogous to a narrowing primitive conversion from long to int as defined in section 5.1.3 of The Java™ Language Specification: if this BigInteger is too big to fit in an int, only the low-order 32 bits are returned. Note that this conversion can lose information about the overall magnitude of the BigInteger value as well as return a result with the opposite sign.
Specified by:
intValue in class Number
Returns:
this BigInteger converted to an int.


Source: https://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html

Wednesday, June 17, 2015

AutoCloseable: the Star behind the scene

Every Java project has different culture as depending on  business requirements, developer or version of Java etc.

ORM libraries make developers' life more easy and resource control is undertaken by external ORM libraries.

I'm not JDBC expert but with Java SE 7 very good  functionality was introduced to Java developers.

Instead closing your prepared statement at the end of code line, by calling closeOnCompletion  method, it will be automatically closed.

I'd like to specify this old but gold feature because some of my friends don't aware of  the autoclosable interface  etc.

http://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html


This is not only for JAVA.SQL also please visit Socket family :).


Saturday, February 7, 2015

Java @ Fosdem 2015





First day

Started with  learning current status of JEP process and continue  with the learning Jigsaw enhancements(http://mreinhold.org/blog/jigsaw-modular-images). We learned the new group about Vulnerability.

Yuppi!!! Corba is still living. I think until last Cobol application will live, Java will keep Corba libs.

....

As I see,
Most of the speakers have github account. You can follow their projects.
https://fosdem.org/2015/schedule/track/java/

....


Second day

Andrew Haley's session was extraordinarily awesome :).

It was a good Summary for many of us ;-)




Summary

Two JavaFull days with news, status updates, "sessions like  tutorial in limited time"  were really good.








Thursday, September 25, 2014

Java 8

Links:
http://cr.openjdk.java.net/~mr/se/8/java-se-8-edr-spec.html
http://ttux.net/post/java-8-new-features-release-performance-code/

Book: Java 8 Lambdas by  Richard Warburton


My favorite section is Lambda-Enabled Design Patterns. It was surprise to me because I did not expect to read anything about the design patterns.
In addition:
Every code line works successfully. It is hardly seen in many books. Have you ever used  the static imports? With the examples of this book, you would be :).

As everybody knows It isn't your Grandmother's Java, anymore!


Book: Java SE 8 for the Really Impatient by Cay S. Horstmann


Streams, Time API, Lambdas, Java FX and Nashorn JS Engine are explained with samples in this book.



If John Lennon would have been lived, He would have been compose a song for Java 8. 




Wednesday, August 6, 2014

When Your Garbage Collector tells you do not remember me ?

@7th chapter of the Java Performance (by Charlie Hunt,..) 

-XX:+DisableExplicitGC and  runtime results of disabling explicit garbage collection  is explained.

The following link is a reference  for every java developer to learn more VM options. (I think the Java Performance also should be read.)

http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html



Wednesday, March 12, 2014

Unbearable Lightness of Using ThreadSafe Objects

Being psychologically @ThreadSafe annotation may "look and feel safe" Effect at the first sight for any Java code.

If your threads use same  variables for accessing/modifing purpose and you miss this issue, your threads can be confused :-).

Sometimes; you trust in web servers' architecture for writing thread safe applications. It's a good way unless your application contains cached objects that might be used by your app's transactions .




Sunday, February 23, 2014

For Sunday Reading

10 years ago, we prefered writing our new applications in Java instead of C++/C,  because it is
platform independent, easy to code, no need for writing destructor (thanks to GC), libraries and  performance results were very close to C++.

But today, everthing  changed :) in many aspects.

Reading the following article made a flashback effect on me:

            http://stevewedig.com/2014/02/17/why-and-how-i-write-java/

I'm wondering 10 years later, why we will use Java?

:-)


Image source: www.123rf.com

Friday, February 21, 2014

Java & Art & History

HISTORY OF ART  & REFLECTIONS ON HISTORY OF JAVA

After the course on Art History:




"I would rather excel others in the knowledge of what is excellent than in the extent of my powers and dominion." Alexander the Great




ART
Java
Gives messages on the sly.
GIVE messages via JSRs/BOOKS/BLOG/EVENTS/MAILGROUPS
Next  year  never be like present
Next  year  never be like present
One Trend triggers the others
One Vote triggers the others








Sources: 
http://en.wikipedia.org/wiki/Gothic_art
http://en.wikipedia.org/wiki/Write_once,_run_anywhere





The Da Vinci Machine Project 

a multi-language renaissance 

for the Java™ Virtual Machine architecture

http://openjdk.java.net/projects/mlvm/




Modular Art -  Modular Java :)



Creative Commons License
Author's comments in this blog are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Friday, December 13, 2013

Little little comes to the middle :)

When i learned this Virtual Java User Group's activities, I remembered my note which belongs to 2 years ago.
http://threadsandlocks.blogspot.com/2011/12/remove-borders.html

Virtual JUG organizes good webinars. 

If you are interested in, please visit:

www.meetup.com/virtualJUG/


Really Good Job :) !

Monday, October 7, 2013

Sweet Java8 is commmiiiinnnggg

Good things come to those who wait :)

One of the keynote topics @JavaOne2013 was Java8 and it brings. it will come with easiest ways to the programmers.

After Java 8 it seems to be easiest Date usage will be with java developers.
After using Java8, would you please tell me how many lines will be deleted from all of the source codes in the projects (all around the world).

When i saw the removeAll advantages,  i found myself thinking this calculation unconsciously :):

Anyway, it comes to its goodparts of Java8, the following slides and the links inside may be helpfull.

http://java.dzone.com/articles/java8-good-parts-javaone-2013

Update:
When  you give Java 8 seminar/training etc, I don't advise you using "Age" topic in your samples:)
this photo belongs to JavaOne2013 Sunday Keynote :-)


Monday, September 16, 2013

Java Compilation Suprises for newbies

Learn how to smart java compiler, make duplicate code lines in your code and after compilation, when you decompile of your compiled source code (.class file) you must see the how optimization is maden :)



Speacially Try-Catch Blocks for that, I prefer!

Wednesday, September 4, 2013

Java, Unknown Threads are perfect strangers, arent they?

Perfect memory usage is necessary for any application.

After write your application it comes to the performance monitoring.

The following comments for heap monitoring.

-verbosegc -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -Xloggc:filename.ext

when you run your application you get the log file filename.ext.

GcViewer is the best for displaying log file.


Then enjoy!

Monday, January 30, 2012

Virtual Developers Day

I really great appriciate to say that the virtual developers day is comingggggg.

For more information you can visit http://www.oracle.com/.


Happy with JAVA!

Eden Space

in other words Heap Memory.

According to forums: The pool from which memory is initially allocated for most objects, as i see a minor garbage collection


As programmer being, when you learn java programming, you start to find details in java.
Eden Space is one of the important spaces for Java. The others are two survivor spaces.
So when you are reading a book about Java Performance, it is the second thing that you learn :) of course it is Eden Space after you learn that what you dont know and what you want to know.

Tuesday, January 24, 2012

Create your sound with Java

Have you ever known that you can make music by using Java.

it is imposible for many years.

Please check the following links and enjoy !


Nice Api:
http://www.jfugue.org/examples.html



http://docs.oracle.com/javase/tutorial/sound/index.html

Wednesday, August 24, 2011

Calling System.gc() is good or not?

According to many developers, Garbage Collection(GB) is triggered by calling Calling "gc" method of System Class. But many developers said that, the VM may or may not decide call GB.

The Latter also emphasize that calling GB is depends on a lot of factors such as VM's algorithms, it's working mode and so on.

When we look at the Class Specification,calling "gc" method is runs garbage collection. The source is as follows:

http://download.oracle.com/javase/6/docs/api/java/lang/System.html


Saturday, July 30, 2011

Welcome Java 7

Yes, approximately we were waiting Java 7 for 11 months.


Here it is available:

http://www.oracle.com/technetwork/java/javase/downloads/java-se-jdk-7-download-432154.html

In the next post, i will inform news about Java7.

Stay with Threads and Locks :).

Wednesday, June 8, 2011

Advices for Java newbies

Hi very nice article i found there.

there is a link :
http://java.dzone.com/articles/10-things-become-outstanding

Details are here:

1. Have strong foundation and understanding on OO Principles
For a Java developer, having strong understanding on Object Oriented Programming is a must. Without having a strong foundation on OOPS, one can't realize the beauty of an Object Oriented Programming language like Java. If you don't have good idea on what OOPS is, even though you are using OOP language you may be still coding in procedural way. Just studying OO principle definitions won't help much. We should know how to apply those OO principles in designing a solution in OO way. So one should have a strong knowledge on Object modeling, Inheritance, Polymorphism, Design Patterns.

2. Master the core APIs
It doesn't matter how strong you are in terms of theoretical knowledge if you don't know the language constructs and core APIs. In case of Java, one should have very strong hands-on experience with core APIs like java.lang.*, I/O, Exceptions, Collections, Generics, Threads, JDBC etc. When it comes to Web application development, no matter which framework you are using having strong knowledge on Servlets, JSPs is a must.

3. Keep coding
Things look simpler when talking about them theoretically. We can give a solution to a problem very easily in theory. But we can realize the depth of the problem when we start implementing our approach. You will come to know the language limitations, or design best practices while coding. So keep coding.

4. Subscribe to forums
We are not alone. There are lots of people working on the same technologies that we are working on. While doing a simple proof of concept on a framework may not give you real challenges, when you start using it on real projects you will face weird issues and you won't find any solution in their official documentation. When starting to work on a new technology the best and first thing to do is subscribe to the relevant technology forums. Whatever the issue you are facing, someone else in the world might have already faced it earlier and might have found the solution. And it would be really really great if you can answer the questions asked by other forum users.

5. Follow blogs and respond
As I already told you are not alone. There are thousands of enthusiastic technology freaks around the world blogging their insights on technology. You can see different perspectives of same technology on blogs. Someone can find great features in a technology and someone else feels its a stupid framework giving his own reasons of why he felt like that. So you can see both good and bad of a technology on blogs. Follow the good blogs and respond/comment on posts with your opinion on that.

6. Read open source frameworks source code
A good developer will learn how to use a framework. But if you want to be an outstanding developer you should study the source code of various successful, popular frameworks where you can see the internal working mechanism of the framework and lot of best practices. It will help a lot in using the frameworks in very effective way.

7. Know the technology trends
In the open source software development technology trends keep on changing. By the time you get good idea on a framework that might become obsolete and some brand new framework came into picture with super-set of features. The problem which you are trying to solve with your current framework may be already solved by the new framework with a single line of configuration. So keep an eye on whats coming in and whats going out.

8. Keep commonly used code snippets/utilities handy
Overtime you may need to write/copy-paste same piece of code/configuration again and again. Keeping those kind of configuration snippets like log4.properties, jdbc configuration etc and utilities like StringUtils, ReflectionUtils, DBUtils will be more helpful. I know it itself won't make you outstanding developer. But just imagine some co-developer asks you to help in fetching the list of values of a property from a collection of objects and then you just used your ReflectionUtil and gave the solution in few minutes. That will make you outstanding.

9. Know different development methodologies
Be familiar with various kinds of methodologies like Agile, SCRUM, XP, Waterfall etc. Nowadays choosing the development methodology depends on the client. Some clients prefer Agile and some clients are happy with waterfall model. So having an idea on various methodologies would be great.

10. Document/blog your thoughts on technology
In day to day job you may learn new things, new and better way of doing things, best practices, architectural ideas. Keep documenting those thoughts or blog it and share across the community. Imagine you solved a weird problem occurred while doing a simple POC and you blogged about it. May be some developer elsewhere in the world is facing the same issue on a production deployed application. Think how important that solution for that developer. So blog your thoughts, they might be helpful for others or to yourself.

Source: Here

Saturday, May 14, 2011

[Java Popular Mistakes]Out of memory error:java heap space

When you run your java program which is run on the appplication server or standalone on your operating system, there is a possibility to have a such a type of error "Out of memory error:java heap space".

:) many reasons are can be possible on your code. Before editing java system properties please check your code and control whether any recursive and endless loops are existed!

After checking, if you dont find any logical mistake, you can visit this link:
http://baskarfelix.wordpress.com/2008/08/06/out-of-memory-errorjava-heap-space/

Monday, April 25, 2011

Good Articles for Java

Hi dear visitor,

the following links are very nice for reference notes:

http://blog.xebia.fr/2011/02/17/java-collection-performance/#Classiques


http://alaindefrance.wordpress.com/

http://jawher.wordpress.com/