Showing posts with label how to. Show all posts
Showing posts with label how to. Show all posts

Monday, September 2, 2013

Set memory option for JVM

The -J-Xmx... option tells the Java virtual machine the maximum amount of memory it should use for the heap. Placing a hard upper limit on this number means that the Java process cannot consume more memory than physical RAM available. This limit can be raised on systems with more memory. Current default value is 128MB. Note: Do not set this value to near or greater than the amount of physical RAM in your system or it will cause severe swapping during runtime.

~ details: https://performance.netbeans.org/howto/jvmswitches/

To set -Xmx option in Netbeans:

- Right click project, select Properties.


- Select Run tab, enter your setting in VM Options.


The option -Xmx1g request 1G of maximum memory for JVM. Run the example code in last post to varify.




Wednesday, July 24, 2013

Add JAR in NetBeans

This post describe how to add third party Jar in NetBeans.

Download target JAR. For example, download java-json here, unzip it.

In NetBeans, right click your project, select Properties.


Select Category of Libraries, Compile tab, and click Add JAR/Folder button.


Browse to select the downloaded/unzipped jar file, click OK.


And click OK to finish.


Tuesday, July 23, 2013

Setting up NetBeans IDE for Mobile Development on Windows

Setting up NetBeans IDE for Mobile Development on Windows

This screencast demonstrates the support for the Java ME SDK in NetBeans IDE, showing how to activate JavaME plugins and register the Java ME SDK in the IDE.

Sunday, June 23, 2013

Setup RxTx jar and .so for Ubuntu

The former post describe how to "Install RXTX on Ubuntu". It simple download the files to your system, but Java not know where is it! To work with installed RxTx, you have to setup Build Path to compile the code, and copy the binaries (.so files) to java library path.

Setup Java Build Path in NetBeans:

If build path not set correctly, error of "package gnu.io does not exist" will be thrown.

package gnu.io does not exist
"package gnu.io does not exist" thrown without Build Path set
- Right click your project, select Properties.

Setup project properties
Setup project properties
- Select Libraries in Categories, Compiler tab and click Add JAR/Folder button.

Add JAR/Folder
Add JAR/Folder
- Browse to select RXTXcomm.jar, should be in /usr/share/java folder, and click OK to accept.

Add RXTXcomm.jar
Add RXTXcomm.jar
- Click OK again to finish. It should be compiled without error.

Copy the binaries (.so files) to java library path:

Without corresponding .so files in java library path, you will get error of "UnsatisfiedLinkError: no rxtxSerial in java.library.path" in run time, like this:

java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver
Exception in thread "main" java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1878)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1087)
at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:123)
at serialtest.SerialTest.initialize(SerialTest.java:41)
at serialtest.SerialTest.main(SerialTest.java:109)

UnsatisfiedLinkError
UnsatisfiedLinkError

- Refer to the post "Get property of java library path" to know where is the library folder.

- Copy the binaries librxtxSerial.so and librxtxParallel.so (should be in /usr/lib/jni/) to one of the library folder (for example: /opt/java/jre/lib/i386/).

$sudo cp /usr/lib/jni/librxtxSerial.so /opt/java/jre/lib/i386/librxtxSerial.so
$sudo cp /usr/lib/jni/librxtxParallel.so /opt/java/jre/lib/i386/librxtxParallel.so




Saturday, June 22, 2013

Install RXTX on Ubuntu

RXTX is a full implementation of the Java CommAPI from Sun. It contains native libraries providing serial and parallel communication for the Java Development Toolkit.

A easy way to install RXTX on Ubuntu is using Synaptic Package Manager (Synaptic Package Manager is available in Ubuntu Software Center).

Simple search rxtx in Synaptic Package Manager, and mark to install

Install RxTx on Ubuntu with Synaptic Package Manager
Install RxTx on Ubuntu with Synaptic Package Manager

The jars will be installed in /usr/share/java folder.

- Alternatively, you can use the command in Terminal:
$sudo apt-get install librxtx-java

Remark: It copy the files only. To make it work with Java, you have to "Setup RxTx jar and .so for Ubuntu".


Wednesday, March 20, 2013

Setting up your Java Dev Environment


YouTube Developers Live: Setting up your Java Dev Environment

Want to learn how to setup your IDE and Maven for YouTube API Java development? Join +Ikai Lan and +Ibrahim Ulukaya as they start from scratch and end up with a productive YouTube API Java development environment.

They will cover IDE setup, Maven integration and go over Java code samples of the YouTube Data API v3. Whether you are an experienced developer working through initial YouTube API library setup or a new developer ready to get started, this show will be great DIY guide!


Tuesday, March 5, 2013

Building OpenJFX on Mac with JDK



Building OpenJFX on Mac with JDK b78
Step by step instructions (with some gotcha's!) in building OpenJFX on Mac OS X with JDK b78

Tuesday, February 12, 2013

Obtain API Key for Google Maps API v3

All Maps API applications* should load the Maps API using an API key ~ https://developers.google.com/maps/documentation/javascript/tutorial.

The steps are shown here:

- Visit Google APIs Console (you have to login with your Google account).


- Create a new API Project.


- Enter the name to your project.


- Enable the Google Maps API V3.


- Accept these terms.


- Make sure to select the Project in the left, and select API Access, you can copy the API Key to your application.



Related article:
- Embed Google Maps API v3 in JavaFX WebView.

Friday, February 1, 2013

How to remove JDK in Ubuntu Linux

Java SE 7 Update 13 released, so I have to remove old jdk and install the updated version.

To remove jdk using update-alternatives, open Terminal and type the commands:

sudo update-alternatives --remove "javac" "/home/you/jdk1.7.0_11/bin/javac"
sudo update-alternatives --remove "java" "/home/you/jdk1.7.0_11/bin/java"

remove JDK in Ubuntu Linux
remove JDK in Ubuntu Linux

After remove the old jdk, you can remove the old jdk from your hardisk, and re-install the new JDK 7 and update-alternatives.

Wednesday, January 16, 2013

Install Netbeans IDE 7.2 on release version Windows 8

TO download Netbeans, visit http://netbeans.org/, click the Download button.


Scroll download the select the download option. Java SE in my case.


Run the download file, netbeans-7.2.1-ml-javase-windows.exe.


Click Next to start installation.


Accept the terms in the license agreement, and click Next.


Accept the terms t install JUnit, and click Next.


Select the location to install. The installer will search te installed JDK if exist. Next.


Review all the setting, and click Install.



Finish.



How to run Java Control Panel on Windows 8

To run Java Control Panel on Windows 8, search java in Settings.

Search Java Control Panel in Settings

Java Control Panel

Set PATH to JDK on Windows 8 (official version)

Last post described how to "Download and Install JDK 7 on Windows 8 (Official version)".

After downloaded and install JDK 7 on Windows 8, now open a Command Prompt window to run java or javac...!!!

you can optionally set PATH environment variable to JDK so that you can conveniently run the JDK executable files (javac.exe, java.exe, javadoc.exe, and so forth) from any directory without having to type the full path of the command.

To set path, search "Environment Variables" in "Settings", click "Edit the system environment variables".

Click "Environment Variables".

Select System variables of Path, and click Edit...

Add the location of the bin folder of the JDK installation, in my case it is "D:\Program Files\Java\jdk1.7.0_11\bin".

Now, you can close and re-open Command Prompt window, type java and javac to varify your setting.

Install JDK 7 on Windows 8 (Official version)

In this post, I describe how to download and install JDK 7 (Java SE 7u11 currently) on official Windows 8 (not Preview version).

Note: You must have administrative permissions in order to install the JDK on Microsoft Windows.
Note: Installers for JDK 7u6 and later install the JavaFX SDK and integrate it into the JDK installation directory.

Visit http://www.oracle.com/technetwork/java/javase/downloads/index.html, click the download Java Platform button.

Scroll down to check Accept License Agreement, select Java SE Development Kit 7u11, jdk-7u11-windows-i586.exe for Windows x86.

Run the downloaded installer.

Select optional features and location to install.


Select location to install jre.


Completed.

Next:
- Set PATH environment variable to JDK on Official Windows 8

Tuesday, January 15, 2013

Install JDK 7 and update-alternatives on Ubuntu 12.10

Download update JDK here: http://www.oracle.com/technetwork/java/javase/downloads/index.html, click the DOWNLOAD Java Platform graph.




Scroll download to check the box of Accept License Agreement, and select the package to download. In this case, jdk-7u11-linux-i586.tar.gz for Linux x86 is selected.


Move the downloaded .tar.gz archive binary to the directory you want to install.

Open a Terminal, the the command to unpack the tarball and install the JDK:
$tar zxvf jdk-7u11-linux-i586.tar.gz

For example, if you download the .tar.gz is /home/you, your installed directory will be /home/you/jdk1.7.0_11.

Then, you have to update alternatives for javac and java:
$sudo update-alternatives --install /usr/bin/javac javac /home/you/jdk1.7.0_11/bin/javac 1
$sudo update-alternatives --install /usr/bin/java java /home/you/jdk1.7.0_11/bin/java 1

If you have more than one javac installed, you have to config your javac alternative
$sudo update-alternatives --config javac
$sudo update-alternatives --config java

Finally, delete the downloaded .tar.gz after then.


How to install Synaptic Package Manager on Ubuntu 12.10

Synaptic package Manager is a graphical package manager tool based on GTK+ and APT, to install upgrade and remove software packages in user friendly way.

To install Synaptic Package Manager on Ubuntu 12.10:

- Click the top Ubuntu icon on the left bar, search Package Manager in second tab on bottom. Click the Synaptic Package Manager selection.



- After a moment, Ubuntu Software Center will be opened with Synaptic Package Manager. Click Install.


- You will be asked to enter administrator password to continuous.