Java SE

This category will hold articles for Java SE and Eclipse.

I think Java can be a lot of fun, since it already delivers a lot out of the box.

People who develop Java APIs usually give it a lot of thinking and work.

 

Java EE in comparison to Java SE can be described as a huge collection of Frameworks and API developed around Java SE.

Java EE is not a stand-alone programming language, but based on Java SE.

In case you need to show some web pages in an embedded browser in a Java Rich Client application you can use an SWT component of Eclipse.

This makes it quite easy, if you cannot use JavaFX 2.0 yet in order to do the trick because the client computers are running on older Java versions.

Source Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package dbDesktop;
 
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
 
public class dbDesktopBrowser {
 
	/**
	 * Launch the application.
	 
	 * @param args
	 */
	public static void main(String[] args) {
		Display display = Display.getDefault();
		Shell shell = new Shell();
		shell.setSize(772, 528);
		shell.setText("SWT Application");
		shell.setLayout(new FillLayout(SWT.HORIZONTAL));
 
		Browser browser = new Browser(shell, SWT.NONE);
		browser.setUrl("https://www.some.url");
		browser.refresh();
 
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
 
	}
}

 

If you have to convert a lot of images from one format into another the following code snippet might be of use.

Source Code

1
2
3
4
5
6
7
8
9
10
11
12
13
	@Test
	public void testConvertImages() throws IOException {
		File[] files = FileHandling.getMatchingFilePathFromDirectory(
				".+\\.png", new File("C:\\Users\\xxx\\Upload\\screens\\"));
		int i = 0;
 
		for (File file : files) {
			BufferedImage img = ImageIO.read(file);
			ImageIO.write(img, "jpg", new File(
					"C:\\Users\\xxx\\Upload\\screens\\"
							+ file.getName().replace(".png", ".jpg")));
		}
	}

The class FileHandling is part of a little util file library I implemented and it is not needed to get this working.

 

Whenever you encounter a special task in parsing XML into Java objects (un-marshaling) or Java objects into XML (marshaling) utilizing JAXB, you can get angry quite easily.

Examples are ...

  • no namespace in XML, may it be marshaling or un-marshaling
  • sanitized output into XML when marshaling and vice versa
  • formatted output, which is easier to read

Facing these issues many times, I decided to create a special Eclipse Java project for JAXB marshaling and un-marshaling, which I can reference in other Java projects.

This is much quicker anyhow than repetitive code in different places.

Subcategories

This category provides articles regarding JavaFX as well as e(fx)clipse as this seems to be a good start to deal with JavaFX.

JavaFX has been around for some time now and Oracle is currently triying to enforce it as new standard for Java Rich Client Applications.

Regarding to a developer I know it has had some improvements over the years and it looks like it is going to be a try out worthy successor of AWT (Java), Swing (Java) and SWT (IBM).

However Oracle is trying to push this somewhat new technology into the market for some time now, it has not yet been accepted by the Java community.

Root cause for this seem to be the following reasons.

  • Companies are not asking for Rich Client Applications, but there is a trend for developing Web Applications. Therefore motivation to use anything like AWT, Swing, SWT or JavaFX is low except for private purposes. However JavaFX supports Mobile Applications, which is a big market. Since integration with mobiles is asked by companies as well for web applications and older technologies not supporting it, I can understand Oracle not wanting to provide support for it anymore.
  • Programmers are lazy. If you give them something completely new to learn, it takes quite an effort to get to a stage where you are as fast as using already known technologies. The standard platform for Java development, eclipse is still not providing the same comfortable "what you see is waht you get editors" for JavaFX as it is providing for the older technologies. Until eclipse is not deprecating support for Swing and older technologies like SWT and AWT they will be used by programmers.

I did some research one the internet regarding JavaFX so far but I will try to write more articles in the future about it as I intend to write little tools for myself in Java. For this I of course do not want the hustle of maintaining a JEE server all the time. Therefore JavaFX is intersting for me but I am far from beeing an expert, so try it yourself.

Groups articles regarding eclipse SWT.

A category to collect articles around Apache POI.

Java Architecture for XML Binding (JAXB) provides a fast and convenient way to bind XML schemas and Java representations, making it easy for Java developers to incorporate XML data and processing functions in Java applications. As part of this process, JAXB provides methods for unmarshalling (reading) XML instance documents into Java content trees, and then marshalling (writing) Java content trees back into XML instance documents. JAXB also provides a way to generate XML schema from Java objects.