Packaging POF object class in a jar file

I have the following issue packaging a POF class.
I have two POF classes which are defined in the package oracle.communications.activation.asap.ace;
1. Token.java
2. Asdl.java
For simplicity i package them in the coherence.jar along with the other nessary artifacts.
"tokens-pof-config.xml"
<?xml version="1.0"?>
<pof-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-pof-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-pof-config coherence-pof-config.xsd">
<user-type-list>
<!-- coherence POF user types -->
<include>coherence-pof-config.xml</include>
<!-- com.tangosol.examples package -->
<user-type>
<type-id>1001</type-id>
<class-name>Token</class-name>
</user-type>
<user-type>
<type-id>1002</type-id>
<class-name>Asdl</class-name>
</user-type>
</user-type-list>
<allow-interfaces>true</allow-interfaces>
<allow-subclasses>true</allow-subclasses>
</pof-config>
Then I startup the CacheServer it startsup fine. However when I invoke the POF classes from my weblogic artifacts I get the following error message.
<Oct 26, 2011 10:04:24 PM PDT> <Warning> <EJB> <BEA-010065> <MessageDrivenBean threw an Exception in onMessage(). The exception was:
(Wrapped) java.io.IOException: unknown user type: oracle.communications.activation.asap.ace.Token.
(Wrapped) java.io.IOException: unknown user type: oracle.communications.activation.asap.ace.Token
======================================================================================================================
If I however define the classes in the default package or no package instead of package oracle.communications.activation.asap.ace;
Keeping everything else the same everything works fine.
====================================================================================
What do I need to do to make this work if I am packaging my POF classes not in the default package ?

Hi JK,
Well i have modified my POF classes since then and now created a package for them before I was just playing around and had them defined in a default package.
Second Baby steps here, once I get things working by packaging things in the coherence.jar file I will create my own jar artifact and add it to class path. As it is I have classpath issues. ...
So as I mentioned earlier.
I created the oracle/communications/activation/asap/ace directory added my two POF classes to it and then repackaged the jar.
It returns this error!
2011-10-27 06:48:03.355/4.696 Oracle Coherence GE 3.6.0.4 <Error> (thread=main, member=1): Error while starting service "DistributedCache": (Wrapped) (Wrapped: error configuring class "com.tangosol.io.pof.ConfigurablePofContext") java.lang.NoClassDefFoundError: oracle/communications/activation/asap/ace/Token (wrong name: Token)
So any ideas ?
"tokens-pof-config.xml"
==============
<?xml version="1.0"?>
<pof-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-pof-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-pof-config coherence-pof-config.xsd">
<user-type-list>
<!-- coherence POF user types -->
<include>coherence-pof-config.xml</include>
<!-- com.tangosol.examples package -->
<user-type>
<type-id>1001</type-id>
<class-name>oracle.communications.activation.asap.ace.Token</class-name>
</user-type>
<user-type>
<type-id>1002</type-id>
<class-name>oracle.communications.activation.asap.ace.Asdl</class-name>
</user-type>
</user-type-list>
<allow-interfaces>true</allow-interfaces>
<allow-subclasses>true</allow-subclasses>
</pof-config>
cache-server.sh_
#!/bin/sh
# This will start a cache server
# specify the Coherence installation directory
COHERENCE_HOME=.
# specify the JVM heap size
MEMORY=512m
if [ ! -f ${COHERENCE_HOME}/bin/cache-server.sh ]; then
echo "coherence.sh: must be run from the Coherence installation directory."
exit
fi
if [ -f $JAVA_HOME/bin/java ]; then
JAVAEXEC=$JAVA_HOME/bin/java
else
JAVAEXEC=java
fi
#JAVA_OPTS="-Xms$MEMORY -Xmx$MEMORY -Dtangosol.pof.enabled=true -Dtangosol.pof.config=tokens-pof-config.xml"
#JAVA_OPTS="-Xms$MEMORY -Xmx$MEMORY -Dtangosol.coherence.clusteraddress=224.3.6.0 -Dtangosol.coherence.clusterport=3059"
JAVA_OPTS="-Xms$MEMORY -Xmx$MEMORY"
#JAVA_OPTS="-Xms$MEMORY -Xmx$MEMORY"
$JAVAEXEC -server -showversion $JAVA_OPTS -cp "$COHERENCE_HOME/lib/coherence.jar:." com.tangosol.net.DefaultCacheServer $1
Token.java for example (Asdl.java looks very similar)
================================
package oracle.communications.activation.asap.ace;
import java.io.IOException;
import java.io.Serializable;
import com.tangosol.io.pof.PortableObject;
import com.tangosol.io.pof.PofReader;
import com.tangosol.io.pof.PofWriter;
import java.sql.*;
import java.util.Enumeration;
* This class represents the domain object Token. This class is also packaged on the classpath
* for the Cache-Server when it starts up. The Token class implements the PortableObject format.
* @author Ankit Asthana
public class Token implements PortableObject {
     * The state associated with a token
     * 1 - Unassigned, 2 - Available, 3 - Reserved, 4 - defunct
     private int state;
     * The network ID associated with each token
     private String neID;
     * Unique Token ID, used to identify Tokens
     private String tokenID;
     * State of the token possible
     public static int TOKEN_AVAILABLE = 2;
     public static int TOKEN_RESERVED = 3;
     * The following are static final indices required for the implementation
     * for a POF object, they have to be sequential in order.
     public static final int TOKENID = 0;
     public static final int STATE = 1;
     public static final int NEID = 2;
     * setter Method for state of the token
     * @param state
     public void setState(int state) {
          this.state = state;
     * getter Method for the state of the token
     * @return
     public int getState() {
          return state;
     * setter Method for the network ID
     * @param neID
     public void setNeID(String neID) {
          this.neID = neID;
     * getter Method for the network ID
     * @return
     public String getNeID() {
          return neID;
     * returns the TokenID for the current token
     * @return
     public String getTokenID() {
          return tokenID;
     * Default Constructor required by POJO's, Do not remove!
     public Token() {
     * This is a utility method and returns the state of the token in a String format using the
     * integer value representing the state of the token passed to it.
     * @param tokenStateInteger
     * @return
     public static String tokenToString(int tokenStateInteger) {
          if (tokenStateInteger == TOKEN_AVAILABLE)
               return "Available";
          else if (tokenStateInteger == TOKEN_RESERVED)
               return "Reserved";
          return "Unknown";
     * Parameterized constructor for a token.
     * Can be used to initialize a token with the following parameters
     * @param tokenID: Unique ID representing the Token
     * @param state: The state for the token, by default available
     * @param neID: The network ID this token associates to
     public Token(String tokenID, int state, String neID) {
          this.state = state;
          this.tokenID = tokenID;
          this.neID = "" + neID;
     // ----- PortableObject interface ---------------------------------------
     * The readExternal method is required for the implementation of the POF portableObject.
     * This method is used for serialization purposes
     * {@inheritDoc}
     public void readExternal(PofReader reader) throws IOException {
          tokenID = reader.readString(TOKENID);
          state = Integer.parseInt(reader.readString(STATE));
          neID = reader.readString(NEID);
     * The writeExternal method is required for the implementation of the POF portableObject.
     * This method is used for de-serialization purposes
     * {@inheritDoc}
     public void writeExternal(PofWriter writer) throws IOException {
          writer.writeString(TOKENID, tokenID);
          writer.writeString(STATE, Integer.toString(state));
          writer.writeString(NEID, neID);
Edited by: 807103 on Oct 27, 2011 8:55 AM
Edited by: 807103 on Oct 27, 2011 9:00 AM

Similar Messages

  • Is it possible to call a class in a jar file from JNI environment?

    Hi
    Is it possible to call a class in a jar file from JNI environment?
    Thanks in advance.

    Could you explain a bit more what you are trying to do? (In other words, your question is vague.)
    o If your main program is written in C, you can use JNI to start a JVM, load classes from the jar of your choice, and call constructors and methods of the objects defined in the jar.
    o If your main program is java, and has been laoded from a jar, a JNI routine can call back into java to use the constructors and methods of classes defined in the jar(s).

  • Is it possible to load classes from a jar file

    Using ClassLoader is it possible to load the classes from a jar file?

    URL[] u = new URL[1] ;
    u[0] = new URL( "file://" + jarLocation + jarFileName + "/" );
    URLClassLoader jLoader = new URLClassLoader( u );
    Object clsName = jLoader.loadClass( clsList.elementAt(i).toString() ).newInstance();
    I get this error message.
    java.lang.ClassNotFoundException: ExceptionTestCase
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
    // "file://" + fileLocation + fileName + "/" This works fine from a browser.
    Is there anything I am missing? Thanks for the reply.

  • How  to include the inner classes in a jar file in netbeans ide

    Dear java friends
    how to say to netbeans ide that it has to include the
    inner classes in the jar file.
    (i have one single applet class
    with two inner classes that show up
    in the build/classes file but not in the jar).
    The applet works in the viewer but not
    in the browser (I believe because the
    xxx$yyy etc should be in the jar)
    willemjav

    First, please stop posting the same question multiple times:
    Duplicate of http://forum.java.sun.com/thread.jspa?threadID=5269782&messageID=10127496#10127496
    with an answer.
    Second, If your problem is that you can't do this in NetBeans, you need to post to somewhere that provides NetBeans support - like the NetBeans website's mailing list. These forums do not support NetBeans (or any other IDE) - they are Java language forums.

  • Can I create a JTA EntityManagerFactory in a utility class in a .jar file?

    I have utility classes in a .jar file inside of a .war file deployed in Glassfish 3.1. One of these utility classes, CredentialsUtil, needs to access a database. I can't inject an EntityManager into CredentialsUtil since it is not an EJB. (For security reasons I don't want to make CredentialsUtil an EJB. I want it to be a POJO.)
    In CredentialsUtil I need an EntityManagerFactory that is connected to a datasource defined in Glassfish. Here is the line from CredentialsUtil.java and from the persistence.xml both of which will be in the util.jar file:
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("Credpu");
    <persistence-unit name="Credpu" transaction-type="JTA">
    I can't use RESOURCE_LOCAL since any changes to the datasource configuration must be done in Glassfish rather than changing persistence.xml.
    (The transaction context is not important in CredentialsUtil. It will be called by a WS-Security handler which may not have a transaction context.)
    Can I put the persistence.xml and the CredentialsUtil class that creates the EntityManagerFactory from it inside of the util.jar file (which will be in a .war), or do I have to move the class and a copy of the persistence.xml file out to the .war file? (I'll have to leave persistence.xml in the .jar file too since there are some @Entity in the .jar file. I don't know why but there are @Entity pojos in the .jar file.)
    I'd like to use the existing persistence.xml, but if I can't is there is a way to create an EntityManagerFactory (or EntityManager) that gets its datasource directly from Glassfish, ignoring persistence.xml?
    Thanks.

    Styles in Pages are saved in the documents (or templates). There is no easy method for adding a style to a built-in template (and it is strongly recommended that you do not tamper with them). You can open a built- in template, add your style and save it as a user template so that your new style will be standard in documents created from that template.

  • Can I use addAuditTrailEntry(String message, Object detail) in a jar file?

    I have a lot of jar libraries that I need to import into my BPEL process. It's not practical for me to copy all the code flatly into an embedded java / bpelx.
    How can I call the addAuditTrailEntry method inside the classes in my jar file?
    e.g.
    I import libraries.jar at the top of my .bpel file.
    In my embedded java I do:
    MyClass myclass = new MyClass();
    myclass.doSomething();
    In the public void doSomething() method I would like to write to the audit trail directly. Currently I am simply having the doSomething() method return a String with a summary of everything it has done. This is not good enough because the method takes a long time to complete and I need a running audit trail so that I can take actions depending on what is going on in it.
    I can't seem to find the documentation... I assume in my MyClass.class I will need to import some bpel jars so that it can comprehend what a bpel process is... then pass the current process instance into the MyClass file so that it can call its addAuditTrailEntry method... is this right?
    I envision something like:
    import orabpeljars.jar
    public MyClass(BPELProcess process)
    process.addAuditTrailEntry("In MyClass Constructor");
    ------------------------------------------

    I have a lot of jar libraries that I need to import into my BPEL process. It's not practical for me to copy all the code flatly into an embedded java / bpelx.
    How can I call the addAuditTrailEntry method inside the classes in my jar file?
    e.g.
    I import libraries.jar at the top of my .bpel file.
    In my embedded java I do:
    MyClass myclass = new MyClass();
    myclass.doSomething();
    In the public void doSomething() method I would like to write to the audit trail directly. Currently I am simply having the doSomething() method return a String with a summary of everything it has done. This is not good enough because the method takes a long time to complete and I need a running audit trail so that I can take actions depending on what is going on in it.
    I can't seem to find the documentation... I assume in my MyClass.class I will need to import some bpel jars so that it can comprehend what a bpel process is... then pass the current process instance into the MyClass file so that it can call its addAuditTrailEntry method... is this right?
    I envision something like:
    import orabpeljars.jar
    public MyClass(BPELProcess process)
    process.addAuditTrailEntry("In MyClass Constructor");
    ------------------------------------------

  • How to combine the classes from 2 jar files into 1?

    Hi there
    I have got 2 jar files with the same name but the classes that they contain are different. So, I want to combine those 2 files into 1. Could anyone please tell me how to add the classes in a jar file to another jar file?
    Thanks for your help!
    From
    Edmund

    The jar utility allows you to extract files as well as put them into a jar. This is in the java docs.
    You might have to hand modify the manifest file if it was hand modified in the first place. All you should have to do is copy the text from one file to another. The manifest will have the same name so you will have to extract to different dirs so it isn't overwritten.
    Steps:
    -Create dir1 and dir2
    -Extract jar1 into dir1, Extract jar2 into dir2.
    -Manually examine manifests and combine if needed.
    -Copy files from one dir to another.
    -Use jar tool to create new jar.

  • Accessing classes in external jar files

    I have a jar file called main. I want it to be able to acces the classes in another jar file say test.jar how do i do this.
    Thank you

    ok, if i have this right...
    you have 2 directories that hold 2 .jars, right?
    plugins/ -------- build/plugins .jar
    systemModuals/ ------- DiaryUI and Loader .jar
    Your main JAR is diary?
    Diary.jar
    you want Diary to run with the jars inside plugins and systemmoduals?
    you set the "class-path:" tag like this....
    write this manifest file. save it as Manifest.txt and put it in your home dir.
    Main-Class: YourMainClass
    Class-Path: Diary.jar plugins/this.jar systemmoduals/diaryui.jar
    <make sure to hit enter, go to the next line>
    command line to your parent directory.
    jar cmf Manifest.txt Diary.jar build/main/*.class
    you should be set to go.
    use
    jar xf META-INF/MANIFEST.MF
    to read the present manifest that netbeans has created
    if necessary

  • How do I list all classes in a Jar file?

    How do I list all classes in a Jar file?

    Its no problem if the jar file contains classes, but I have an EAR file, which contains a jar-file, and I want to list all classes in that jar-file.
    I would like to do something like this:
    java.util.jar.JarFile jarfile = new java.util.jar.JarFile( new File("/meYear.ear"), true );
    java.util.jar.JarEntry jar = jarfile.getJarEntry( "myJar.jar" );
    // Cast it to a new JarFile:
    java.util.jar.JarFile newJar = (java.util.jar.JarFile)jar;
    But the method getEntry returns something like jarFile$JarEntry, if I try to class cast it I get an classCastException.

  • Dinamyc class loading and jar files

    I'm new to java. I would like to load some plugins in my application (it's going to be packaged as a jar at the end). I managed to find some dinamyc class loading examples but they search for the classes to load in a directory.
    This is the code:
        public static void main(String[] args) {
            File pluginDirectory = new File("src/pluginsreloaded/plugins");
            if (!pluginDirectory.exists()) {            // the plugin directory does not exist
                System.out.println("The plugins directory does not exist!");           
                return;
            FilenameFilter filter = new FilenameFilter() {
                public boolean accept(File dir, String name) {
                    return name.endsWith(".class");
            String[] pluginFiles = pluginDirectory.list(filter);
            for (int i = 0; i < pluginFiles.length; i++) {
                if (pluginFiles.indexOf("$") == -1) {
    System.out.println("Loading: " + pluginFiles[i].substring(0, pluginFiles[i].length() - 6));
    IPlugin plugin = pm.loadPlugin(pluginFiles[i].substring(0, pluginFiles[i].length() - 6));
    System.out.println(plugin.description());
    protected static IPlugin loadPlugin(String name) {
            // Query the plugin list for the plugin
            PluginFactory _plugin = (PluginFactory) pluginList.get(name);
            if (_plugin == null) {          // the plugin is not loaded
                try {
                    Class.forName("pluginsReloaded.plugins." + name);
                    // The plugin makes an entry in the plugin list
                    // when loaded
                    _plugin = (PluginFactory) pluginList.get(name);
                    if (_plugin == null) {
                        return null;
                } catch (ClassNotFoundException e) {
                    System.out.println("Plugin " + name + " not found!");
            return _plugin.create();
        }IPlugin is an interface. I am using netbeans 5.0. The error I get is this:
    Exception in thread "main" java.lang.NoClassDefFoundError: pluginsReloaded/plugins/plugin1 (wrong name: pluginsreloaded/plugins/plugin1)
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
            at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
            at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Class.java:164)
            at pluginsreloaded.PluginManager.loadPlugin(PluginManager.java:30)
            at pluginsreloaded.Main.main(Main.java:44)
    Java Result: 1As far as I can see it can't find the class. My question is how can I load the class/where can I find it?
    Thanks.

    You can use the java.util.jar.JarFile class to enumerate the contents of a jar. It's not good practice to search for plugins in this way though. A plugin may well involve serveral classes, which don't all have to be internal. Furthermore its wise to avoid any comitment about the mechaism by which class files are to be fetched. You might want to do it remotely, some time, or load them from a database.
    What seesms to be the standard approach is to put a list of plugin classes into the jar as a text file.
    Plugins for a given purpose usually implement some specified interface, or extend some abstract class to which their objects can be cast once loaded (without this they aren't really much use).
    Say your plugins implment org.myorg.WidgetFactory then you put a list of them, one fully qualified name to a line, in a file or jar entry called META-INF/services/org.myorg.WidgetFactory. You framework picks up all such files from the classpath using ClassLoader.getResources() and loads all the classes whose names if finds, hence you can add new sets of plugins just by adding a new jar or class directory to the class path.

  • How do I import classes in a jar file?

    I have the following directory structure, each directory is a seperate package of the same name as the directory
    RPGUniversal
    RPGMap
    RPGCharacter
    RPGCharacter is not done yet so I am ignoring that package for now.
    RPGCharacter and RPGMap both depends on classes inside the RPGUniversal Package, but are independant of eachother and RPGUniversal is completely independant.
    I want to place each package in it's own .jar file for use as a library in later programs.
    I placed all the compiled classes for RPGUniversal inside the proper directory structure, I then used this command to place it in a jar:
    jar -cf ./RPGUniversal.jar ./RPGUniversal/*
    I then tested the contents with this command:
    exodist@Abydos:/stuff/JProject/test$ jar -tf RPGUniversal.jar
    META-INF/
    META-INF/MANIFEST.MF
    RPGUniversal/ADTs/
    RPGUniversal/ADTs/t1.jpg
    RPGUniversal/ADTs/t2.jpg
    RPGUniversal/ADTs/t3.jpg
    RPGUniversal/ADTs/t4.jpg
    RPGUniversal/ADTs/Coordinates.class
    RPGUniversal/ADTs/RPGImage.class
    RPGUniversal/ADTs/FrameSet.class
    RPGUniversal/ADTs/ImageTester.class
    RPGUniversal/Exceptions/
    RPGUniversal/Interfaces/
    RPGUniversal/Interfaces/RPGCharacter.class
    RPGUniversal/Interfaces/RPGItem.class
    RPGUniversal/Interfaces/RPGObject.class
    RPGUniversal/Interfaces/Trackable.class
    RPGUniversal/Interfaces/Tracker.class
    RPGUniversal/Interfaces/RPGMapComponent.class
    RPGUniversal/Interfaces/RPGMap.class
    so far all good, next I delete the RPGUniversal directory leaving the only file in the current directory RPGUniversal.jar
    next I create the RPGMap directory and give it the proper .java files and directory tree.
    I then run a script to compile every .java file
    for i in `find ./ -name "*.java"`; do javac "$i"; done
    and I get a ton of dependancy errors:
    exodist@Abydos:/stuff/JProject/test$ for i in `find ./ -name "*.java"`; do javac "$i"; done
    ./RPGMap/BaseClasses/StaticMap.java:13: package RPGUniversal.Interfaces does not exist
    import RPGUniversal.Interfaces.*;
    ^
    ./RPGMap/BaseClasses/StaticMap.java:20: cannot resolve symbol
    symbol : class RPGMap
    location: class RPGMap.BaseClasses.StaticMap
    public abstract class StaticMap implements RPGMap
    ^
    ./RPGMap/ComponentClasses/MapTile.java:9: package RPGUniversal.Interfaces does not exist
    import RPGUniversal.Interfaces.*;
    ^
    ./RPGMap/ComponentClasses/MapTile.java:10: package RPGUniversal.ADTs does not exist
    import RPGUniversal.ADTs.*;
    ^
    ./RPGMap/ComponentClasses/MapTile.java:16: cannot resolve symbol
    symbol : class RPGObject
    location: class RPGMap.ComponentClasses.MapTile
    public class MapTile implements RPGObject
    ^
    ./RPGMap/ComponentClasses/MapTile.java:19: cannot resolve symbol
    symbol : class RPGImage
    location: class RPGMap.ComponentClasses.MapTile
    private RPGImage MyImage;
    ^
    ./RPGMap/ComponentClasses/MapTile.java:31: cannot resolve symbol
    symbol : class Coordinates
    location: class RPGMap.ComponentClasses.MapTile
    public boolean CheckForCollision(Coordinates C)
    ....the list goes on........
    how do I tell it to look inside the RPGUniversal.jar file to find the required classes?
    here is a directory tree so you can see how it is set up:
    ls -R1
    RPGMap/
    RPGUniversal.jar
    ./RPGMap:
    BaseClasses/
    ComponentClasses/
    ExternalInterfaces/
    HigherClasses/
    InternalInterfaces/
    ./RPGMap/BaseClasses:
    StaticMap.java
    ./RPGMap/ComponentClasses:
    MapTable.java
    MapTile.java
    TableList.java
    TileSet.java
    ./RPGMap/ExternalInterfaces:
    ./RPGMap/HigherClasses:
    DynamicMap.java
    ./RPGMap/InternalInterfaces:

    The JAR file needs to be in the compliers classpath : javac -classpath "$CLASSPATH:RPGUniversal.jar" "$i"

  • JNI: How to use FindClass to get a class in a Jar file?

    Is it possible to use the FindClass method of the JNI environment object to get a class that is in a jar file? My sample application was working when my class files were in the local directory. Now that I have replaced the class files with a jar file containing the classes, the app no longer works. I'd appreciate tips from anyone who knows how to do this.
    -Andreas

    Is it possible to use the FindClass method of the
    JNI environment object to get a class that is in a
    jar file? My sample application was working when my
    class files were in the local directory. Now that I
    have replaced the class files with a jar file
    containing the classes, the app no longer works. I'd
    appreciate tips from anyone who knows how to do this.It has nothing to do with JNI.
    The method uses the class path just like any other class loading situation in java. The reason it worked before is because your class path included the directory. It doesn't work now because either the jar is not in the class path or there is something wrong with the class path.

  • Java class uses another class in a Jar file (How do I make Java see it)?

    I am trying to figure out how do I make Javac see the thinlet.class in the thinlet.jar.
    I have developed an XUL xml interface and a java program that calls the interface shown below:
    //package thinlet.demo;
    import thinlet.*;
    public class UI extends Thinlet
    { public UI () throws Exception {add(parse("UI.xml"));}
    public static void main(String[] args) throws Exception
    { new FrameLauncher("UI", new UI(), 600, 600); }}
    when I do the normal compile, I get an error:
    UI.java:4: cannot find symbol
    symbol: class Thinlet
    public class UI extends Thinlet {
    ^
    UI.java:7: cannot find symbol
    symbol : method parse(java.lang.String)
    location: class thinlet.demo.UI
    add(parse("UI.xml"));
    ^
    UI.java:12: cannot find symbol
    symbol : class FrameLauncher
    location: class thinlet.demo.UI
    new FrameLauncher("UI", new UI(), 600, 600);
    ^
    3 errors
    This thinlet class should be in the thinlet.jar that I have added the directory to the path, the directory and jarfile name to the System CLASSPATH and it couldn't see it. So finally I tried putting the thinlet.jar in the same directory to no avail. I've searched the web for some time an cannot find anything that specifically speaks to compiling a program that has parent classes in a Jar.
    Any help is definitely appreciated.

    This thinlet class should be in the thinlet.jar that I have added the directory to the path, the directory and jarfile name to the System CLASSPATH and it couldn't see it. So finally I tried putting the thinlet.jar in the same directory to no avail. I've searched the web for some time an cannot find anything that specifically speaks to compiling a program that has parent classes in a Jar.
    Any help is definitely appreciated.You just still haven't provided the jar in the classpath, or you're not using the right class name. Is the class really named thinlet.Thinlet? Or are you thinking "import thinlet.*" means to import all classes in a jar named thinlet.jar? Because the latter is not true. You need to import classes, not jar file names.

  • Locating classes given many JAR files

    This may seem a basic thing, but I'm having trouble figuring out how people locate the correct JAR file to include when given just the package and class name.
    In searching for a solution to a problem I'd come across web document that tell me all about a particular class or set of classes that will solve this or that problem. The document goes on to give me the package name that the class(es) belong to. The problem is, these classes are in a JAR file and the document doesn't tell me the name of the JAR file or where to get it - assuming I don't have it.
    Assuming I do have the JAR file, that JAR file is usually in a directory with many more JAR files (for example, WSAD includes a whole bunch of JAR files or me). What's the best way to locate the package and/or class file(s) within all these JAR files? Why don't authors tell us the name of the JAR file these class(es) are in? Does anyone else have this problem besides me?

    Haven't tried. But still worth having a look into this free plug-in for Eclipse.
    http://www.icewalkers.com/Linux/Software/520170/JAR-Class-Finder.html
    Thanks
    Venkat

  • Class Loader for Jar Files

    I have a set of Jar files which i need to load using Custom Class Loader. Any one who has Javacode for Custom Class Loader for loading Jar files send it. The Jar files are local jar files.

    Here is the class loader I use:
    import java.net.URL;
    import java.net.URLClassLoader;
    import java.net.JarURLConnection;
    import java.lang.reflect.Method;
    import java.lang.reflect.Modifier;
    import java.lang.reflect.InvocationTargetException;
    import java.util.jar.Attributes;
    import java.io.IOException;
    * A class loader for loading jar files, both local and remote.
    public class JarClassLoader extends URLClassLoader {
        private URL url;
        private URL[] m_urlList = new URL[10];
         * Creates a new JarClassLoader for the specified url.
         * @param url the url of the jar file
        public JarClassLoader(URL url,ClassLoader cl) {
             super(new URL[] { url },cl);
          this.url = url;
        public JarClassLoader(URL[] urlList,ClassLoader cl) {
             super( urlList,cl);
          this.m_urlList = urlList;
         * Returns the name of the jar file main class, or null if
         * no "Main-Class" manifest attributes was defined.
        public String getMainClassName() throws IOException {
          URL u = new URL("jar", "", url + "!/");
             JarURLConnection uc = (JarURLConnection)u.openConnection();
             Attributes attr = uc.getMainAttributes();
             return attr != null ? attr.getValue(Attributes.Name.MAIN_CLASS) : null;
         * Invokes the application in this jar file given the name of the
         * main class and an array of arguments. The class must define a
         * static method "main" which takes an array of String arguemtns
         * and is of return type "void".
         * @param name the name of the main class
         * @param args the arguments for the application
         * @exception ClassNotFoundException if the specified class could not
         *            be found
         * @exception NoSuchMethodException if the specified class does not
         *            contain a "main" method
         * @exception InvocationTargetException if the application raised an
         *            exception
         public void invokeClass(String name, String[] args) throws ClassNotFoundException,
                NoSuchMethodException,
                InvocationTargetException
             Class c = loadClass(name);
             Method m = c.getMethod("main", new Class[] { args.getClass() });
             m.setAccessible(true);
             int mods = m.getModifiers();
             if (m.getReturnType() != void.class || !Modifier.isStatic(mods) || !Modifier.isPublic(mods)) {
             throw new NoSuchMethodException("main");
             try {
               m.invoke(null, new Object[] { args });
             } catch (IllegalAccessException e) {
             // This should not happen, as we have disabled access checks
    }

Maybe you are looking for

  • X200 HD refuses to be partitioned -- am totally stumped!

    I just purchased an X200 whose HD I'm trying to partition, in order to separate OS and software from my data. I've successfully done this several times over the years on other IBM/Lenovo laptops (a T40, a T43, a T60 and a T61) using version 8.01 of P

  • Good iphone car mount that works with case?

    I need a car mount for my iPhone so that I can use the phone's GPS app. I've looked around and so far I can only find mounts that work for iPhones without any case. I would rather not have to remove the case everytime I got in my car, so are there an

  • Analytic Windowing - Positive/Negative Range

    Hi, In analytic functions, we can say RANGE BETWEEN  x  PRECEDING       AND      y  PRECEDINGwhere x and y are expressions (not necessarily literals), as long as x and do not evaluate to negative numbers. If we know when we write the code that x and/

  • 4th Generation I Pod Touch Freezes Up

    My ipod stopped working months ago, so I put it away; last night I charged it and this morning the ipod worked like nothing had happened, I went to change the time and date and the device froze again.  Any suggestions?

  • How can I use the remote that comes with MacBook?

    I have a MacBook remote (old macbook, not the pro). I no longer have the macbook computer, but I hope I can still use the remote. I do not know how. Please help me.