The java code i am executing is,

package samplejena;

import com.hp.hpl.jena.query.expr.NodeValue;
import com.hp.hpl.jena.query.function.FunctionBase1;

import java.net.*;
import java.text.SimpleDateFormat;
import java.util.*;

public class LastModified extends FunctionBase1
{
private static final SimpleDateFormat format = new
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
private Map _cache;
public LastModified()
{
_cache = new HashMap();
}
public NodeValue exec(NodeValue nodeValue)
{
String value = nodeValue.asString();
if (_cache.containsKey(value))
{
return (NodeValue)_cache.get(value);
}
        String lastModified = "";
try {
lastModified = getLastModified( nodeValue.asString() );
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

        NodeValue date = NodeValue.makeDate(lastModified);
        _cache.put(value, date);
        return date;
}
public String getLastModified(String link) throws Exception
{
URL url = new URL(link);
URLConnection connection = url.openConnection();
connection.setAllowUserInteraction(false);
long secs = connection.getLastModified();
String xsdDate = dateToXSD(secs);
return xsdDate;
}
public String dateToXSD(long secs)
{
Date date = new Date(secs);
return format.format(date);
}
}



On Wed, Aug 8, 2018 at 1:14 PM, Arunkumar Krishnamoorthy <akris...@ncsu.edu>
wrote:

> Hello Andy,
>
> I am getting the following issue when i run the code,
>
> Caused by: java.lang.ClassNotFoundException: com.hp.hpl.jena.query.
> function.FunctionBase1
> at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.j
>
> I have added the .class file in the directory. Do i need to package the
> dependancy jars also? Please advice.
>
> Regards,
> Arun
>
> On Tue, Aug 7, 2018 at 2:11 PM, Arunkumar Krishnamoorthy <
> akris...@ncsu.edu> wrote:
>
>> It is executing now Andy. Thanks a lot. I missed to add the directory.
>> Thanks again for this help.
>>
>> On Tue, Aug 7, 2018 at 2:06 PM, Andy Seaborne <a...@apache.org> wrote:
>>
>>>
>>>
>>> On 07/08/18 18:07, Arunkumar Krishnamoorthy wrote:
>>>
>>>> So my JENA_CP
>>>> is JENA_CP='/home/ak/Downloads/apache-jena-3.8.0/lib/*:/home/ak
>>>> /Documents'.
>>>>
>>>
>>> Does the file
>>>
>>> /home/ak/Documents/samplejena/LastModified.class
>>>
>>> exist?
>>>
>>>
>>>
>>>> /home/ak/Documents location has the classfile/jar of the code
>>>>
>>>> But still when i run this command,
>>>>
>>>> /home/ak/Downloads/apache-jena-3.8.0/bin/arq --data
>>>> /home/ak/Desktop/dataset.rdf --query /home/ak/Desktop/query.rq
>>>>
>>>> I am getting the below error,
>>>>
>>>> ak@akrish12:~$ /home/ak/Downloads/apache-jena-3.8.0/bin/arq --data
>>>> /home/ak/Desktop/dataset.rdf --query /home/ak/Desktop/query.rq
>>>> 12:41:35 WARN  ClsLoader            :: Class not found:
>>>> samplejena.LastModified
>>>> 12:41:35 WARN  exec                 :: URI
>>>> <java:samplejena.LastModified>
>>>> has no registered function factory
>>>> -------------
>>>> | title | r |
>>>> =============
>>>> -------------
>>>>
>>>>
>>>> Regards,
>>>> Arun
>>>>
>>>> On Tue, Aug 7, 2018 at 12:20 PM, Andy Seaborne <a...@apache.org> wrote:
>>>>
>>>> The list doesn't accept attachments.
>>>>>
>>>>> JENA_CP="$JENA_HOME"'/home/ak/Documents'
>>>>>>>
>>>>>>
>>>>> This needs to be a valid java classpath.
>>>>>
>>>>> $JENA_HOME is directory of the Jena installation.
>>>>>
>>>>> In the original it says:
>>>>>
>>>>> JENA_CP="$JENA_HOME"'/lib/*'
>>>>>
>>>>> the .../lib/* (NB single quotes - no * expansion) puts all the jars in
>>>>> that direct on the classpath.
>>>>>
>>>>> For you:
>>>>>
>>>>> JENA_CP='/home/ak/Downloads/apache-jena-3.8.0/lib/*'
>>>>>
>>>>> You need to add the package/classfile tree for you code.
>>>>>
>>>>> As you have: java:samplejena
>>>>>
>>>>> Suppoose /DIR is the top of that directory tree so "samplejena"  is one
>>>>> directory within /DIR.
>>>>>
>>>>> You then want:
>>>>>
>>>>> JENA_CP='/home/afs/jlib/apache-jena/lib/*:/DIR'
>>>>>
>>>>> : is the classpath separator.
>>>>>
>>>>>      Andy
>>>>>
>>>>> On 07/08/18 16:25, Arunkumar Krishnamoorthy wrote:
>>>>>
>>>>> Hello,
>>>>>>
>>>>>> I have attached the file with the change, i am getting Could not find
>>>>>> or
>>>>>> load main class arq.arq
>>>>>>
>>>>>> My classpath location is /home/ak/Documents. Please let me know
>>>>>> whether
>>>>>> my change is correct.
>>>>>>
>>>>>> Regards,
>>>>>> Arun
>>>>>>
>>>>>>
>>>>>> On Tue, Aug 7, 2018 at 11:11 AM, Andy Seaborne <a...@apache.org
>>>>>> <mailto:
>>>>>> a...@apache.org>> wrote:
>>>>>>
>>>>>>      Hi - Please send email to the jena users mailing list.
>>>>>>
>>>>>>      (It is correct if it works!)
>>>>>>
>>>>>>           Andy
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>
>

Reply via email to