Java

Nested tables? Do you actually mean TreeTables? PrimeFaces is throwing out so many new widgets every 6 months, some old features are just not being improved anymore. Check out their new wisget set in showcases. Also, what is maybe not always the best solution, but often helps, is to develop your own custom widget. It is actually easy to do, and will give you the best understanding of how certain components function. I work with JSF for almost 8 years already, I am a senior dev, and I still manage to find enormous amount of bugs within their framework. Some of them I also reported, which were later turned into features in the new versions.

OperatingSystem:

ProgrammingLanguage:

When explaining the highly technical problem such as this, one really must specify all the integrating parts, including the versions of each and every libraries in use. This seems to me as one of those problems that are so simple, that overthinking prevents you from solving it. Have you perhaps tried reaching out to .NET community online (you must know stackoverflow)? But before posting there, read this https://stackoverflow.com/help/how-to-ask :). If that doesn't help, I have some friends who are .NET gurus and will be more then wiling to help :)
Also, I must denote, days and days of such agony were my usual weekly routine when I started working as a junior dev.

OperatingSystem:

ProgrammingLanguage:

integrate a Google Map into a Website using JSF

If you are implementing a Website using JSF and Java, and you want to add a Google Maps, there can be different solutions.

You can use one of the PrimeFaces components. There is a nice little component called GMap: http://www.primefaces.org/showcase/ui/gmapHome.jsf
However it is doesn’t offer every function we are used to have with a Google Map.

A better possibility is to use gmap4jsf. To add a Google Mao into your JSF Page you need to add the gmaps4jsf tab library.
Here is a simple Example of who you can use it:

<%@ taglib uri="http://code.google.com/p/gmaps4jsf/" prefix="m" %>

The Example in the attachment uses the latitude and longitude to present a marker on a specific point on the Google Map. The picture in the attachment presents the resulting outcome.

Further examples can be found using the following link:
http://www.mashups4jsf.com/gmaps4jsf-examples/home.jsf

The gmpas4jsf provides JSF tags that make it easy to create a map using latitude and longitude or an address. You can add a marker to the map or an information text. Also some nice additional function like a zoom in and out or switching between map types can be used.
You can read an overview about the functionalities of gmaps4jsf using the following link: http://code.google.com/p/gmaps4jsf/

To calculate your coordinates you can use the Java API for Google geocoder v3
An overview about the functionality and also information about the Maven Repository can be found under the following link: http://code.google.com/p/geocoder-java/
The geocoder is an easy possibility if you want to search for a specifiy city or route that you want to presents in your Google Map.

Taggings:

Kill running process in a Unix-based console with the example of the Java Web Server Grizzly

1. Step: We need to find the proper running process in the background, for that we will use the command...


ps aux

... which lists all running processes which mostly is too long of a list:


jurgen 39191 0.0 0.8 904472 69368 ?? S 2:19PM 0:11.78 /Applications/Google Chrome
jurgen 39043 0.0 0.2 2524472 13976 ?? Ss 9:51AM 0:02.62 com.apple.security.pboxd
jurgen 38473 0.0 0.0 2467260 432 ?? Ss Tue03PM 0:00.20 com.apple.XType.FontHelper
...

So we filter out only the process that we are looking for, by using the command 'grep' and using the console pipe '|' to concatenate the commands


ps aux | grep java

Result:

jurgen 39543 0.1 1.9 4845420 163316 s008 S+ 5:49PM 0:07.18 /Library/Java/JavaVirtu... exec:java
jurgen 39573 0.0 0.0 2432768 460 s007 S+ 6:08PM 0:00.00 grep java

Now this returns us the proper process but also the 'grep' process itself which we were just running in our pipe, to filter this, we concatenate yet another 'grep -v grep':


ps aux | grep java | grep -v grep

... and we only get the process we need

jurgen 39543 0.1 1.9 4845420 163316 s008 S+ 5:49PM 0:07.18 /Library/Java/JavaVirtu... exec:java

Now that we have identified our process with its process number 39543 (second column in our process), we can terminate it with the 'kill -9'* command, as follows:


kill -9 39543

* If your wondering: The -9 parameter tells the kill-Command to send a SIGKILL signal to our process

In conclusion the following - more generic code - needs to be executed:

ps aux | grep [server_process_name] | grep -v grep
kill -9 [identified_process_id]

Taggings:

Stop Java process

Steps:

1. After login to the server where the process was running, we look for the Java process to be stopped (since the application is in Java, this should be visible in the process list). The "ps aux" command searches through all running processes and the "grep" command filters based on a key word:

ps aux |grep java

2. In order to be sure that our process is still active, we can look also for the specific name of the application:

ps aux |grep java|grep [application_name]

3.a. In case there are no other Java processes on the server (as it can be verified from the results of the first command), the easiest would be to kill all the Java processes:

killall -9 java

3.b. In case there are several Java processes running on the server, then from the results of the first command we can identify the process ID of our Java application. This process ID can then used for stopping the process:

kill -9 [process_ID]

Taggings:

Running Protégé 4.1 with JVM6

Solution

Problem description:
The problem occurs as Protégé 4.1 was build and working with Java version.
If you use version >6, like on up-to-date systems than you have to modify some things.

Precondition:
• Having also JVM (version 6) installed on your computer.

Steps:
1. Choose when downloading Protégé 4.1, download without JVM
2. When running the installer you have to choose a JVM at some point
3. Instead of choosing the up-to-date Java 1.7 choose instead Java 1.6 runtime
4. Run the application, be happy ;)

Manually install the Java Runtime Environment

On October 16, 2012 Apple has started to disable Java applets in Mac OS X 10.6, 10.7 and 10.8:
https://support.apple.com/kb/DL1572
https://support.apple.com/kb/DL1573

If you installed any maintenance updates for Mac OS X after that date, Java applets won't work.

You have to download and install the Java Runtime Environment yourself from
https://www.java.com/en/

Taggings:

Enabling Java in Firefox 3.6

1. Since Firefox 3.6, the Java is treated just like all other plugins and no longer has a enable check box in Tools > Options > Content. We can enable or disable Java plugin (and also all plugins) via Tools > Add-ons > Plugins.

2. What if the Java plugin does not appear in Tools > Add-ons > Plugins (you can also checked it by typing about:plugins in the address bar). It means that you have to install Java (before you can use Java in your Firefox). Since Firefox 3.6 and later versions you need the Next-Generation Java™ Plug-In present in Java 6 U10 and later.
These are how you can do it in various operating system (taken from http://kb.mozillazine.org/Java):

On Mac OS X
You can use the Mac OS X Software Update feature to update Java.
Note: The Java Embedding Plugin is bundled with current Mac distributions of Mozilla browsers, including Firefox and SeaMonkey. This utility allows browsers other than Apple's Safari to use the most recent versions of Java on Mac OS X.

On Linux
1. Download the Linux version of the Java software.
2. When the download is finished, execute the .bin file as root and follow the prompts.
3. When the installation has completed, run this command in the plugins directory of your Firefox installation:
ln -s /your_path_here/java/j2re1.5.0/plugin/i386/ns7/libjavaplugin_oji.so libjavaplugin_oji.so
4. Firefox 3.6 and later need the Next-Generation Java Plug-In
See Manual Installation and Registration of Java Plug-in for Linux (at java.sun.com)
Run this command in the plugins directory of your Firefox installation to create a symbolic link to the Java plugin (replace xx with the current Java version):
ln -s /usr/your_path_here/java/jre1.6.0_xx/lib/i386/libnpjp2.so libnpjp2.so

On Solaris Intel
1. Install the Solaris Intel version of the Java JRE or SDK.
2. When the installation has completed, run this command in the plugins directory of your Firefox installation:
ln -s /your_path_here/jre/plugin/i386/ns610/libjavaplugin_oji.so .

On Windows
Automatic update: The Java Update feature automatically checks for updates in Windows 2000/XP/Vista at scheduled intervals and notifies you when an update is available so that you can install it. If you have administrative privileges, you can also check for updates yourself and install them from the Java Control Panel (Start -> Control Panel -> Java -> "Update" tab).

Manual install or update:
1. Go to Java.com and click on the Free Java Download button.
2. Click on the Download Now button to start the online installation.
3. Close and restart your browser after the installation is complete.
If you prefer an offline installation, go to the Java SE Downloads page (see above for links) select the Java SE Runtime Environment (JRE) and save the offline installer (e.g., "jre-6u10-windows-i586-p.exe" for JRE 6 Update 10) to any convenient location, close your browser and run the installer.

Important: Previous to JRE 6 Update 10, installing or updating to a newer Java version would add a new Java Runtime Environment (JRE) instead of replacing the existing version. For example, if you already have JRE 6 Update 7 installed and later install JRE 6 Update 10, you would end up with two JRE versions installed in separate directories. You can remove older Java versions via Windows Control Panel "Add or Remove Programs", to save disk space and because older versions often contain security vulnerabilities.

Starting with JRE 6 Update 10, future Java updates will patch the current version by default instead of adding an additional version. For example, if you previously installed JRE 6 Update 10 in the C:\Program Files\Java\jre6 directory, and in the future you install JRE 6 Update 14, the version 6u14 installer does not create a new directory. Instead, it updates the pre-existing "jre6" directory with the new 6u14 content (JRE Update 10 will no longer exist). This will prevent an accumulation of unused and potentially insecure older JRE versions.

How to install the JBoss Tools on Eclipse

The following is the solution of install: Prerequisites: Eclipse IDE for Java EE Developers is installed I guess that you all probably have worked or at least have an idea what Java EE is, if not then here is a short explanation of Java EE. Java Platform, Enterprise Edition (Java EE) builds on the solid foundation of Java Platform, Standard Edition (Java SE) and is the industry standard for implementing enterprise-class service-oriented architecture (SOA) and next-generation web applications. The SDKs contain Sun GlassFish Enterprise Server, previously named Sun Java System Application Server, and provide support for Java EE 5 specifications. For more information look on Internet. 1. Start Eclipse. Click the Help menu and go to Software Updates -> Find and Install. 2. Click the radio button next to “Select for new features to install” and click Next. 3. Add a new remote site by clicking on the “New Remote Site” button. In the name field put in “JBossTools Stable Update Site” and for the URL put in “http://download.jboss.org/jbosstools/updates/stable/” then click OK. Make sure the JBossTools Stable Update Site is checked then click Finish. 4. Eclipse’s Update Manager will connect to the JBossTools site and parse the features to be displayed. On the Search Results dialog window, click the check box next to JBossTools Stable Update Site to install all the features under JBossTools Stable Update Site: 2.0.1.GA and Mozilla Libraries. Click Next. 5. Accept the terms and conditions in the license agreements after reading them and click Next. Make sure all the features you want to be installed are on the “Features to install” list then click Finish to start the actual install. 6. Once the downloading and installing is complete, restart Eclipse so all changes can be applied.

Taggings:

Send SMS in Java

 You can use this free Java sample program to send SMS from your PC using GSM modem connected to your computer to your COM port. You also need to download and install the Java comm api from Sun.This program needs the following java files to function.1. SerialConnection.java (This file is used to connect to your COM port from your java program)2. SerialConnectionException.java (This file is for handling serial connection exceptions in your Java program)3. SerialParameters.java (This program is used to set your COM port properties for connecting to your com port from your java program)4. Sender.java (This is the program that implements runnable and sends SMS using the serial connection)5. SMSClient.java (This java class is the main class that can be instantiated in your own java program and called to send SMS. This program in turn will use all the above four files internally to send out your SMS). /*
*
* A free Java sample program
* A list of java programs to send SMS using your COM serial connection
* and a GSM modem
*
* @author William Alexander
* free for use as long as this comment is included
* in the program as it is
*
* More Free Java programs available for download
* at http://www.java-samples.com
*
*
* Note: to use this program you need to download all the 5 java files
* mentioned on top
*
*/
public class SMSClient implements Runnable{

public final static int SYNCHRONOUS=0;
public final static int ASYNCHRONOUS=1;
private Thread myThread=null;

private int mode=-1;
private String recipient=null;
private String message=null;

public int status=-1;
public long messageNo=-1;

public SMSClient(int mode) {
this.mode=mode;
}

public int sendMessage (String recipient, String message){
this.recipient=recipient;
this.message=message;
//System.out.println("recipient: " + recipient + " message: " + message);
myThread = new Thread(this);
myThread.start();
// run();
return status;
}
public void run(){

Sender aSender = new Sender(recipient,message);

try{
//send message
aSender.send ();

// System.out.println("sending ... ");

//in SYNCHRONOUS mode wait for return : 0 for OK,
//-2 for timeout, -1 for other errors
if (mode==SYNCHRONOUS) {
while (aSender.status == -1){
myThread.sleep (1000);
}
}
if (aSender.status == 0) messageNo=aSender.messageNo ;

}catch (Exception e){

e.printStackTrace();

}

this.status=aSender.status ;

aSender=null;

}
}  

Taggings:

Pages

Subscribe to Java