Java

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:

Connect remotely located Java application and database using JBoss, EJB

The Java application which serves as client-side software should be implemented as form of JavaBeans which are serializable.  Server-side software should be adopted to EJB(Enterprise Java Bean) which uses JBoss application server to communicate with database and client-side software components.What is serialization:In computer science, in the context of data storage and transmission, serialization is the process of converting an object into a sequence of bits so that it can be persisted on a storage medium (such as a file, or a memory buffer) or transmitted across a network connection link to be "resurrected" later in the same or another computer environment.[1] When the resulting series of bits is reread according to the serialization format, it can be used to create a semantically identical clone of the original object. For many complex objects, such as those that make extensive use of references, this process is not straightforward.What is JBoss:JBoss Application Server (or JBoss AS) is a free software/open-source Java EE-based application server. Because it is Java-based, the JBoss application server operates cross-platform: usable on any operating system that Java supports. JBoss AS was developed by JBoss, now a division of Red Hat.

Taggings:

How to remote deploy a Web service to Apache Tomcat from within a Java program

1. Introduction to the problem:
There are various possible ways to solve the problem, some major requirements are however:

1. To write a software application
2. To make it transfer the Webservice over the Internet
3. A Servlet is to be copied to the Webapps directory of Tomcat

Some of the ways to solve the problem are:
1. Development of additional software for the server (beside of Tomcat) for the data transfer
2. Development of a Webservice to be placed inside Tomcat for the data transfer
3. Use of Tomcats WWW Management Interface for the data transfer

All three approaches are practicable.
However, the first two approaches require additional software which is to be installed beforehand. The third approach only needs a running Tomcat Application Server on the remote machine.

Therefore the way to go, which is described in this article is "just" to utilize Tomcats WWW Management Interface in software. This approach is very versatile, but has also many pitfalls, and various considerations are necessary. The proposed approach is suitable for one ore more webservices. If in the following only one is mentioned, it also means that more could be in place.

This article does not provide an exhaustive description for solving the problem, but is meant to give some guidance to avoid some of the major problems encountered by solving this task.

2. Requirements
There are two basic requirements:
- An already developed and packaged Webservice
- A properly set up server running Apache Tomcat

An introduction into Webservices would exceed the scope of this article, some previous knowledge is required. It should be noted however, that there are two major ways to use Webservices with the proposed approach. One is to create a Webservice (for example using JAX-WS) and pack it into a .war archive (this is a .jar archive renamed to .war) which is then to be deployed, the other is to use a dedicated Webservice engine (Apache Axis2 can be used with Tomcat) together with a Webservice, and these are then to be packed into a .war archve containing both, which is then to be deployed. For details on compatibility and packaging Webservices (for Axis2 you would package .aar files, these are .jar archives renamed to .aar) into an engine see its documentation.

[Note: The .jar files are incompatible with .zip!]

Another basic requirement is a running Apache Tomcat. For Linux as an OS this is a simple task: Only the login credentials are to be set. For MS-Windows there is some additional work necessary: As of Tomcat Version 6.0.18 the parameters "antiJARLocking" and "antiResourceLocking", both (!) must be set, otherwise an undeployment would fail. For details on configuration and possible drawbacks see the Apache documentation.

3. Compression (in Java)

To execute a tool like Jar (from the JDK) directly from Java issue the following code:

Process p1 = Runtime.getRuntime().exec("CommandLineToBeExecuted");

Don't forget to wait (!) until the command is finished:

BufferedReader input1 = new BufferedReader(new InputStreamReader(p1.getInputStream()));
String line1;
while ((line1 = input1.readLine()) != null) {/*Must wait for the program to finish*/}
input1.close();

4. Programmatically accessing Tomcats WWW Management Interface
Accessing a Web Interface programmatically means to execute "clicks" on links or to start a file upload from a software. Various APIs exist for accessing an interface over HTTP. In Java the java.net.HttpURLConnection is sufficient. As the upload address "http://TomcatHost:8080/manager/html/upload" is to be used. In general it is necessary "to repeat" what would be otherwise performed by a web browser.

The exact procedures would again exceed the scope of this article. However lots of sample code is available on the net. The following description outlines some adaptations necessary to work with Tomcat:

For uploading a .war archive
- Create an HttpURLConnection to the upload address
- Set several properties, some of which are
- "Log in"
# conn.setRequestProperty("Authorization", "Basic " + new BASE64Encoder().encode(loginString.getBytes())); //loginString has the format: "name:password"
- Make sure the "RequestMethod" is "POST"
# conn.setRequestMethod("POST");
- Assemble the data to be send; See various resources on the net.
- Make sure the Content-Disposition is something like that: "Content-Disposition: form-data; name=\"deployWar\";" + " filename=\"" + "foo.war" + "\"" + "\r\n"
Using something different than exactly "deployWar" may lead to failure
- For authentication the "BASE64Encoder" is necessary. The undocumented "sun.misc.BASE64Encoder" should not be used. However one could copy the files "BASE64Encoder" and "CharacterEncoder" from the OpenJDK sources to gain the same functionality.

For following or executing ("clicking") links the procedure is very similar, but
- Use "GET" instead of "POST"
- Don't use multipart content type any more
- Use the URL that is to be "clicked"

The execution of links gives lots of management possibilites. The most important are

List of running Servlets:
[http://TomcatHost:8080/manager/html/]

Undeployment:
[http://TomcatHost:8080/manager/undeploy?path=/foo]

With the latter the deployed Servlet can be undeployed.

Taggings:

How Java RMI Works

RMI applications often comprise two separate programs, a server and a client. A typical server program creates some remote objects, makes references to these objects accessible, and waits for clients to invoke methods on these objects. A typical client program obtains a remote reference to one or more remote objects on a server and then invokes methods on them. RMI provides the mechanism by which the server and the client communicate and pass information back and forth. Such an application is sometimes referred to as a distributed object application

Distributed object applications need to do the following:
* Locate remote objects. Applications can use various mechanisms to obtain references to remote objects. For example, an application can register its remote objects with RMI's simple naming facility, the RMI registry. Alternatively, an application can pass and return remote object references as part of other remote invocations.
* Communicate with remote objects. Details of communication between remote objects are handled by RMI. To the programmer, remote communication looks similar to regular Java method invocations.
* Load class definitions for objects that are passed around. Because RMI enables objects to be passed back and forth, it provides mechanisms for loading an object's class definitions as well as for transmitting an object's data

The server calls the registry to associate (or bind) a name with a remote object. The client looks up the remote object by its name in the server's registry and then invokes a method on it. The receiver can download the definition of an object's class if the class is not defined in the receiver's Java virtual machine.
All of the types and behavior of an object, previously available only in a single Java virtual machine, can be transmitted to another, possibly remote, Java virtual machine. RMI passes objects by their actual classes, so the behavior of the objects is not changed when they are sent to another Java virtual machine. This capability enables new types and behaviors to be introduced into a remote Java virtual machine, thus dynamically extending the behavior of an application

Taggings:

Pages

Subscribe to Java