| database search using Lucene |
|
 |
Index ‹ java-programmer
|
- Previous
- 1
- byte arrays fun...I am using data compression java.util.zip package. My problem is I
need to do it repeatedly, as in the code below, and am working on very
large strings. What is the proper way to "nullify" or realease the
memory that can be freed after using the byte arrays? Does setting
them to null actually cause that memory (heap? stack?) to be freed? I
am running out of memory and think this is where it is happening.
Thanks so much for any help...
Inflater i = new Inflater ();
i.setInput ( bufferWork );
byte[] decompressedBuffer = new byte[ maxCountersSize +
increaseSize ];
long decompressedReturn = i.inflate ( decompressedBuffer );
if ( i.getTotalOut () > maxCountersSize ) {
maxCountersSize = i.getTotalOut ();
}
String uncompressedString = new String ( decompressedBuffer,
i.getTotalOut () );
i.end ();
then to clean up
decompressedBuffer = null;
- 1
- threads/84778: libpthread busy loop/hang with Java when handling signals and Runtime.execThis is still happening on FreeBSD 6.0-STABLE as of 12/6/2005.
World and kernel were compiled without any CPUTYPE or CFLAGS options, as
was Java.
This problem is trivial to reproduce. One merely has to start httpd.sh in
Resin 3.0 with no arguments, wait for the JVM to start running, and hit
^Z or ^C.
The process then goes into an infinite loop in kse_release. truss -p
shows the following:
kse_release(0x8056f44) = 0 (0x0)
kse_release(0x8056f44) = 0 (0x0)
kse_release(0x8056f4c) = 0 (0x0)
kse_release(0x8056f44) = 0 (0x0)
kse_release(0x8056f44) = 0 (0x0)
kse_release(0x8056f4c) = 0 (0x0)
ktrace shows a bit more detail of the infinite loop:
21357 java CALL gettimeofday(0xbf275e70,0)
21357 java RET gettimeofday 0
21357 java CALL gettimeofday(0xbf275ec0,0)
21357 java RET gettimeofday 0
21357 java CALL kse_release(0x8056f4c)
21357 java RET kse_release 0
21357 java CALL gettimeofday(0xbf275e70,0)
21357 java RET gettimeofday 0
21357 java CALL gettimeofday(0xbf275ec0,0)
21357 java RET gettimeofday 0
21357 java CALL kse_release(0x8056f4c)
21357 java RET kse_release 0
gcore -s 21357; gdb /usr/local/jdk14/bin/java core.21357 shows:
Cannot get thread info: generic error
#0 0x4809f1af in pthread_testcancel () from /usr/lib/libpthread.so.2
#1 0x480a01dd in __error () from /usr/lib/libpthread.so.2
#2 0x4808adeb in pthread_getschedparam () from /usr/lib/libpthread.so.2
#3 0x4808feef in pthread_create () from /usr/lib/libpthread.so.2
#4 0x48465f10 in os::create_thread () from /usr/local/jdk1.4.2/jre/lib/i386/client/libjvm.so
#5 0x484afb28 in JavaThread::JavaThread () from /usr/local/jdk1.4.2/jre/lib/i386/client/libjvm.so
#6 0x483f927c in JVM_StartThread () from /usr/local/jdk1.4.2/jre/lib/i386/client/libjvm.so
followed by a smashed-looking stack for about 60 frames, and then:
#65 0x485735c0 in __JCR_LIST__ () from /usr/local/jdk1.4.2/jre/lib/i386/client/libjvm.so
#66 0x4a3c20d7 in ?? ()
#67 0xbf073d00 in ?? ()
#68 0xbf073d48 in ?? ()
#69 0x4839032b in JavaCalls::call_helper () from /usr/local/jdk1.4.2/jre/lib/i386/client/libjvm.so
Previous frame inner to this frame (corrupt stack?)
Note that the valid-looking portion of the stack trace still isn't valid
higher than pthread_create(), though this could have still been a result
of the process still making calls while gcore was running, since the
process does not respond to the STOP signal.
I'm inclined to suspect that this is a Java bug, considering the smashed
stack.
Nick
--
"The aptly-named morons.org is an obscenity-laced screed..."
-- Robert P. Lockwood, Catholic League director of research
Nick Johnson, version 2.1 http://web.morons.org/
- 1
- objection?hi
this website http://www.idiom.com/~zilla/Computer/javaCbenchmark.html
say java is same as or sometime faster than C.
But why swing is so slow?
thanks
from Peter (email***@***.com)
- 2
- Mysteriously appearing Timer thread does not allow JVM to dieHi All,
In my application, a "Timer-1" thread seems to appear out of nowhere
and it does not let the application to shut down. This thread belongs
to a ThreadGroup that I create within the application and it starts
while another thread of the same ThreadGroup is executing. I am able to
pinpoint to fixed block of code during the execution of which, this
thread appears.
I did like to know if there is a way I can track and find out where
this thread is starting from ?
thanks in advance,
Chandresh
Here is what I get on Ctrl+Brk:
Full thread dump Java HotSpot(TM) Client VM (1.5.0_02-b09 mixed mode,
sharing):
"Timer-1" prio=5 tid=0x02e37df8 nid=0x9a8 in Object.wait()
[0x033cf000..0x033cf9
e8]
at java.lang.Object.wait(Native Method)
- waiting on <0x23189cf8> (a java.util.TaskQueue)
at java.lang.Object.wait(Object.java:474)
at java.util.TimerThread.mainLoop(Timer.java:483)
- locked <0x23189cf8> (a java.util.TaskQueue)
at java.util.TimerThread.run(Timer.java:462)
"DestroyJavaVM" prio=5 tid=0x00037948 nid=0xfc waiting on condition
[0x00000000.
.0x0007fae8]
"Low Memory Detector" daemon prio=5 tid=0x00a6dda0 nid=0x95c runnable
[0x0000000
0..0x00000000]
"CompilerThread0" daemon prio=10 tid=0x00a6c978 nid=0xb8 waiting on
condition [0
x00000000..0x02c0f6c0]
"Signal Dispatcher" daemon prio=10 tid=0x00a6bc10 nid=0x188 waiting on
condition
[0x00000000..0x00000000]
"Finalizer" daemon prio=9 tid=0x00a68fd0 nid=0xb88 in Object.wait()
[0x02b8f000.
.0x02b8fa68]
at java.lang.Object.wait(Native Method)
- waiting on <0x23074288> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
- locked <0x23074288> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
at
java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)
"Reference Handler" daemon prio=10 tid=0x00a46af8 nid=0xa2c in
Object.wait() [0x
02b4f000..0x02b4fae8]
at java.lang.Object.wait(Native Method)
- waiting on <0x23074308> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:474)
at
java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
- locked <0x23074308> (a java.lang.ref.Reference$Lock)
"VM Thread" prio=10 tid=0x00036318 nid=0x3a4 runnable
"VM Periodic Task Thread" prio=10 tid=0x00a6efe8 nid=0xffc waiting on
condition
- 2
- 6
- Eoror on compile jdk16 on FreeBSD 7.0 amd64Hello, I have problem when I want to compile java/jdk16
This is the last lines of my compilation
WARNING: The directory HOTSPOT_DOCS_IMPORT_PATH=/NO_DOCS_DIR \n
does not exist, check your value of ALT_HOTSPOT_DOCS_IMPORT_PATH. \n
WARNING: The bsd compiler must be version 3.3 \n Specifically
the GCC compiler. \n You appear to be using compiler version:
4.2 \n The compiler was obtained from the following location:
\n /usr/bin/ \n Please change your compiler. \n
WARNING: Importing CUPS from a system location \n Sanity check passed.
mkdir
-p /usr/ports/java/jdk16/work/control/build/bsd-amd64/hotspot/outputdir
mkdir
-p /usr/ports/java/jdk16/work/control/build/bsd-amd64/hotspot/import
cd ../../hotspot/make ; \ gmake ALT_SLASH_JAVA=/java
ARCH_DATA_MODEL=64
ALT_OUTPUTDIR=/usr/ports/java/jdk16/work/control/build/bsd-amd64/hotspot/outputdir
ALT_EXPORT_PATH=/usr/ports/java/jdk16/work/control/build/bsd-amd64/hotspot/import
PREVIOUS_JDK_VERSION=1.5.0 ALT_BOOTDIR=/usr/local/diablo-jdk1.5.0
FULL_VERSION="1.6.0_03-p4-ddurieux_12_jun_2008_01_18-b00"
JDK_VERSION=1.6.0_03 COOKED_JDK_UPDATE_VERSION=30 COOKED_BUILD_NUMBER=0
JDK_MKTG_VERSION=6u3 JDK_MAJOR_VERSION=1 JDK_MINOR_VERSION=6
JDK_MICRO_VERSION=0 all_product gmake[1]: Entering directory
`/usr/ports/java/jdk16/work/hotspot/make' gmake VM_TARGET=product
generic_build2 gmake[2]: Entering directory
`/usr/ports/java/jdk16/work/hotspot/make' mkdir
-p /usr/ports/java/jdk16/work/control/build/bsd-amd64/hotspot/outputdir
cd /usr/ports/java/jdk16/work/control/build/bsd-amd64/hotspot/outputdir;
\ gmake -f /usr/ports/java/jdk16/work/hotspot/build/bsd/Makefile \
LP64=1 HOTSPOT_BUILD_VERSION=1.6.0_03-p4-ddurieux_12_jun_2008_01_18-b00
JAVA_HOME=/usr/local/diablo-jdk1.5.0
GAMMADIR=/usr/ports/java/jdk16/work/hotspot MAKE_VERBOSE=y product
gmake[3]: Entering directory
`/usr/ports/java/jdk16/work/control/build/bsd-amd64/hotspot/outputdir'
gmake -f /usr/ports/java/jdk16/work/hotspot/build/bsd/Makefile checks
gmake[4]: Entering directory
`/usr/ports/java/jdk16/work/control/build/bsd-amd64/hotspot/outputdir' /usr/local/diablo-jdk1.5.0/bin/javap
javax.xml.transform.TransformerFactory > /dev/null 2>&1; \ if [ $? -ne
0 ]; then \ /usr/local/diablo-jdk1.5.0/bin/java -version; \ echo "***
An XSLT processor (J2SE 1.4.x or newer) is required" \ "to bootstrap
this build" 1>&2; \ exit 1; \
fi /libexec/ld-elf.so.1: /usr/local/lib/compat/libpthread.so.2:
Undefined symbol "__malloc_lock" *** An XSLT processor (J2SE 1.4.x or
newer) is required to bootstrap this build gmake[4]: ***
[check_j2se_version] Error 1 gmake[4]: Leaving directory
`/usr/ports/java/jdk16/work/control/build/bsd-amd64/hotspot/outputdir'
gmake[3]: *** [bsd_amd64_compiler2/debug] Error 2 gmake[3]: Leaving
directory
`/usr/ports/java/jdk16/work/control/build/bsd-amd64/hotspot/outputdir'
gmake[2]: *** [generic_build2] Error 2 gmake[2]: Leaving directory
`/usr/ports/java/jdk16/work/hotspot/make' gmake[1]: *** [product] Error
2 gmake[1]: Leaving directory `/usr/ports/java/jdk16/work/hotspot/make'
gmake: *** [hotspot-build] Error 2 *** Error code 2
Stop in /usr/ports/java/jdk16.
*** Error code 1
Stop in /usr/ports/java/jdk16.
I have the compat6x installed
I think the problem is in '/usr/local/lib/compat/libpthread.so.2:
Undefined symbol "__malloc_lock"'
Can you hel me, I search since 2 week :/
Thanks
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 9
- chaning fonts *only* w/ SynthHey all,
I want the same interface appearance I have now, which is the Metal
LaF, but I just want to make the fonts different. Same style, smaller
fonts. I installed Synth and have the following XML defined ...
<synth>
<style id="default">
<font name="Helvetica" size="10"/>
</style>
<bind style="default" type="region" key=".*"/>
</synth>
If I understand this correctly, doesn't this make the font size
Helvetica 10 (globally using .*) as default, and the rest of the LaF
should stay the same style, right?
The problem is, this makes the default fonts correct all over my
application, but the rest of the GUI is completely ... styleless. Is
there anyway for my menus, buttons, etc... to stay as is using the
Metal LaF, yet change *only* the font size?
Any help much appreciated.
- 10
- greedy methodHello all
I want to know whether there is any greedy approach for job sequencing
with variable job completion times..
if there is no greedy approach how to prove it...
- 10
- Powerbuilder and javaCan someone tell me whether Java can access poserbuilder pbd files, and if
so, how???
- 10
- Question for WebObjects programmers
I am in the process of trying to create a new newsgroup specifically for
the discussion of WebObjects, and I since I have seen some WebObjects talk
in this newsgroup, I would like to get some feedback on this.
Foremost, is there any interest in a WebObjects-specific newsgroup? Since
it is a Java-only platform now, can it/should it just be left for
discussion in comp.lang.java.* newsgroups?
Another question is are there any other newsgroups where WebObjects
discussion happens? It seems to me that most discussion currently happens
in Apple's and The Omni Group's mailing lists.
If there was a WebObjects newsgroup, what do you envision it being?
If anyone could give me some feedback so I can polish up my submissions
to news.groups, I would appreciate it.
- 12
- Help - Emulator package for clientsHi,
I need to a put together a simple J2ME all-inclusive emulator package
that a non-technical client can extract and run.
I was able to do this with the old Sprint WTK (v2.0) by just including
the appdb, lib and bin subdirectories with the jad & jar files nested
in the bin folder.
But, I'm no longer able to get this to work now that I've upraded to
Sprint WTK 3.0
Can someone suggest another emulator that allows you to neatly package
an archive for a non-technical client?
This is to present a game primarly developed for Sprint handsets.
Thanks,
Jeremy
- 14
- javascript - netscapeI've make a simple applet and I must call javascript function.
With nescape and firefox I've to much problem that I don't understand.
Must I do some browser's settings ?
import netscape.javascript.*;
import java.applet.*;
public class ProvaReflect extends Applet {
private JSObject window = null;
public void init(){}
public void start(){
JSObject win = (JSObject)JSObject.getWindow(this);
}
}
Error:
Java Plug-in 1.5.0_04
.....
netscape.javascript.JSException
at netscape.javascript.JSObject.getWindow(Unknown Source)
at ProvaReflect.start(ProvaReflect.java:15)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
--
Questa ?una firma automatica di MesNews.
Sito: http://www.mesnews.net
- 16
- call.invoke
Hi all
I'm calling a method from a web service that doesn't take parameters
My code is erroring on call.invoke();
Can someone tell me what i'm doing wrong
Many thanks
URL endpoint = new
URL("http://localhost:6822/Test/services/extService");
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(endpoint);
call.setOperationName("methodName");
SOAPHeaderElement element = new SOAPHeaderElement("", "HeaderName");
element.setObjectValue(value);
call.addHeader(element);
//String result = (String)call.invoke(new Object[] {});
call.invoke()
- 16
- [Q] HttpServletRequest.getCookies()Hi,
This method getCookies() returns Cookie[] but I can't understand which
cookie does it contens
Only those which refers to the server or all clients cookies ?
- 16
- JDWP JNI AGENT_ERROR_NO_JNI_ENV MustangFolks,
I'm trying to use Mustang (1.6.0-beta2-b86) and Eclipse 3.2
I'm running a little test application, an ordinary "Java Application"
project.
Intermittently, perhaps once out of 5 or 10 times, after the program
runs,
and after a System.println that it executes as the last statement in
the
main() routine, I get the following in the Eclipse console window in
red
(i.e., it was presumably written to System.err):
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return
code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):
[../../../src/share/back/util.c:820]
Can't find anything about this anywhere. Anybody have any ideas?
jim g
|
| Author |
Message |
amitatgroups

|
Posted: 2007-8-3 19:33:00 |
Top |
java-programmer, database search using Lucene
I need example for database search using Lucene.
I found many example Lucene with file but not on Database please guide
me
Thanks...
|
| |
|
| |
 |
Manish Pandit

|
Posted: 2007-8-4 7:14:00 |
Top |
java-programmer >> database search using Lucene
On Aug 3, 4:33 am, email***@***.com wrote:
> I need example for database search using Lucene.
>
> I found many example Lucene with file but not on Database please guide
> me
>
> Thanks...
In case of a database, you write the index by customizing it. For a
file, lucene and index the entire file but for a db it does not know
what all columns/tables you'd want indexed.
Step 1 - Create an index writer just like you would with a file
Step 2 - Create 1 document per record (this can be an aggregate -
anything you'd want to link a search result to). In this doc, keep
adding fields along with the values you'd want to index or store. Like
this:
myDoc.add(new Field("first_name",rs.getString("first_name"),
Field.Store.YES, Field.Index.YES) ) ;
I cannot really say what you'd want stored, index or both but I hope
you have a general idea on how storing, indexing or doing both
matters.
Step 3 - Close the writer.
Hope this helps.
-cheers,
Manish
|
| |
|
| |
 |
Joe Attardi

|
Posted: 2007-8-4 13:13:00 |
Top |
java-programmer >> database search using Lucene
On Aug 3, 7:33 am, email***@***.com wrote:
> I need example for database search using Lucene.
>
> I found many example Lucene with file but not on Database please guide
> me
You might want to try the Lucene mailing list. I am on that list right
now and the regular posters are very, very helpful with all sorts of
Lucene questions. All the info is here: http://lucene.apache.org/java/docs/mailinglists.html
|
| |
|
| |
 |
Amit Jain

|
Posted: 2007-8-18 13:29:00 |
Top |
java-programmer >> database search using Lucene
when i am executing below code, getting Exception :->
"no segments* file found in org.apache.lucene.store.FSDirectory@C:
\dbindex: files:"
on line "IndexWriter writer=new IndexWriter(new File("c:\
\dbindex"),new StandardAnalyzer(),false);"
I m getting above Exception
import java.sql.*;
import java.io.*;
import org.apache.lucene.index.*;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.Field.*;
/**
* @author apurohit
*
*/
public class DBIndex {
/**
* @param args
*/
private Connection con;
private String dbDriver,connectionURL,user,password;
public DBIndex()
{
con=null;
dbDriver="com.mysql.jdbc.Driver";
connectionURL="jdbc:mysql://192.168.1.4:3306/startvisitindia";
user="root";
password="";
}
public void setDBDriver(String driver)
{
this.dbDriver=driver;
}
public void setConnectionURL(String connectionURL)
{
this.connectionURL=connectionURL;
}
public void setAuthentication(String user,String password)
{
this.user=user;
this.password=password;
}
public Connection getConnection()
{
try{
Class.forName(dbDriver);
con=DriverManager.getConnection(connectionURL,user,password);
}
catch(Exception e){
e.printStackTrace();
}
return con;
}
private boolean isIndexExist(String indexPath)
{
boolean exist=false;
try{
IndexReader ir=IndexReader.open(indexPath);
exist=true;
ir.close();
}catch(IOException e){
System.out.println("ioexception:-> "+e);
}catch(Exception e){
System.out.println("exception:-> "+e);
}
return exist;
}
public void performIndexing(String indexPath)
{
try{
Connection connection=getConnection();
String query="select DestId,Name,StateName,DestinationDescription
from destination";
Statement statement=connection.createStatement();
ResultSet contentResutlset=statement.executeQuery(query);
IndexWriter writer=new IndexWriter(new File("c:\\dbindex"),new
StandardAnalyzer(),false);
while(contentResutlset.next()){
//Adding all fields' contents to a single string for indexing
String contents=contentResutlset.getString(2)+"
"+contentResutlset.getString(3)+" "+contentResutlset.getString(4);
//Extracting and adding tags to contents string for creating index
/*
String tagQuery="select t.tag_name from tags t,taggedcontents tc
where tc.content_id = '"+contentResutlset.getString(1)+"' and
tc.tag_id=t.tag_id";
Statement tagStatement=connection.createStatement();
ResultSet tagResultset=tagStatement.executeQuery(tagQuery);
while(tagResultset.next()){contents=contents+"
"+tagResultset.getString(1);}
System.out.println("Indexing Content no.(ID) " +
contentResutlset.getShort(1)+"\n"+contents);
*/
//Creating index for a single content(record in contents table)
Document doc = new Document();
doc.add(new Field("contents",
contents,Store.NO,Index.TOKENIZED,TermVector.YES));
doc.add(new
Field("id",contentResutlset.getString(1),Store.YES,Index.UN_TOKENIZED,TermVector.NO));
writer.addDocument(doc);
//writer.close();
}
writer.close();
}//try
catch(Exception e){
e.printStackTrace();
}//catch
}
public static void main(String[] args) {
DBIndex dbi=new DBIndex();
try{
Connection connection=dbi.getConnection();
String query="select DestId,Name,StateName,DestinationDescription
from destination";
Statement statement=connection.createStatement();
ResultSet contentResutlset=statement.executeQuery(query);
System.out.println("111");
IndexWriter writer = new IndexWriter(new File("c:\\dbindex"),new
StandardAnalyzer(),false);
//System.out.println("IndexWriter:-> "+writer);
while(contentResutlset.next()){
//Adding all fields' contents to a single string for indexing
String contents=contentResutlset.getString(2)+"
"+contentResutlset.getString(3)+" "+contentResutlset.getString(4);
//Extracting and adding tags to contents string for creating index
/*
String tagQuery="select t.tag_name from tags t,taggedcontents tc
where tc.content_id = '"+contentResutlset.getString(1)+"' and
tc.tag_id=t.tag_id";
Statement tagStatement=connection.createStatement();
ResultSet tagResultset=tagStatement.executeQuery(tagQuery);
while(tagResultset.next())
{
contents=contents+" "+tagResultset.getString(1);
}
*/
//System.out.println("Indexing Content no.(ID) " +
contentResutlset.getShort(1)+"\n"+contents);
System.out.println("Indexing Content no.(ID) " +
contentResutlset.getString(1));
//Creating index for a single content(record in contents table)
//Document doc = new Document();
//doc.add(new Field("contents",
contents,Store.NO,Index.TOKENIZED,TermVector.YES));
//doc.add(new
Field("id",contentResutlset.getString(1),Store.YES,Index.UN_TOKENIZED,TermVector.NO));
//writer.addDocument(doc);
//writer.close();
}
//writer.close();
contentResutlset.close();
statement.close();
connection.close();
}//try
catch(Exception e){
System.out.println(e.getMessage());
}//catch*/
}
}
|
| |
|
| |
 |
Manish Pandit

|
Posted: 2007-8-18 13:43:00 |
Top |
java-programmer >> database search using Lucene
On Aug 17, 10:29 pm, Amit Jain <email***@***.com> wrote:
> IndexWriter writer=new IndexWriter(new File("c:\\dbindex"),new
> StandardAnalyzer(),false);
Replace 'false' with 'true' so that lucene can create a new index. If
you are using 'false', make sure the folder exists.
-cheers,
Manish
|
| |
|
| |
 |
Amit Jain

|
Posted: 2007-8-18 13:50:00 |
Top |
java-programmer >> database search using Lucene
Thanks for reply...
Hi,
i replace 'false' with 'true' and folder is exit.
but still same exception.
Thanks...
|
| |
|
| |
 |
Manish Pandit

|
Posted: 2007-8-18 22:23:00 |
Top |
java-programmer >> database search using Lucene
On Aug 17, 10:50 pm, Amit Jain <email***@***.com> wrote:
> Thanks for reply...
>
> Hi,
> i replace 'false' with 'true' and folder is exit.
> but still same exception.
>
> Thanks...
Couple things. Always print stack traces, either on the console or in
a log file.
You are not closing the writer, so lucene cannot aquire the lock file
(that it creates in temp) after indexing. So any subsequent tries
fail.
Put writer.close() in finally along with connection.close().
I was able to uncomment writer.close() (the last one in the code),
change the db stuff to something I already had on my box, and changed
'false' to 'true' without the folder being present, and it worked. I
hope you changed the stuff in main(), as you have duplicate code in
the actual class which does not get called.
Here is the output:
111
Indexing Content no.(ID) 1
Indexing Content no.(ID) 3
Indexing Content no.(ID) 5
Indexing Content no.(ID) 6
Indexing Content no.(ID) 7
Indexing Content no.(ID) 9
Indexing Content no.(ID) 10
Here is the folder it created:
Directory of C:\dbindex
08/18/2007 07:17 AM <DIR> .
08/18/2007 07:17 AM <DIR> ..
08/18/2007 07:17 AM 20 segments
1 File(s) 20 bytes
2 Dir(s) 406,626,304 bytes free
-cheers,
Manish
|
| |
|
| |
 |
Amit Jain

|
Posted: 2007-8-19 19:59:00 |
Top |
java-programmer >> database search using Lucene
Thanks for your reply...
Done...
Thanks
|
| |
|
| |
 |
Amit Jain

|
Posted: 2007-8-21 3:31:00 |
Top |
java-programmer >> database search using Lucene
Hi,
I am getting compile time error symbol not found on line
doc.add(Field.Text("contents", new FileReader(f)));
doc.add(Field.Keyword("filename", f.getCanonicalPath()));
of method indexFile(IndexWriter writer, File f)
when i look into class Field i didn't found any thing about Text and
Keyword symbol.
what i have to do to resolve above compile time error...
/**
*
*/
import java.sql.*;
import java.io.*;
import org.apache.lucene.index.*;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.Field.*;
/**
* @author apurohit
*
*/
/**
* This code was originally written for
* Erik's Lucene intro java.net article
*/
public class FileIndex {
public static void main(String[] args) throws Exception {
File indexDir = new File("fileindex");
File dataDir = new File("txt_file");
int numIndexed = index(indexDir, dataDir);
}
// open an index and start file directory traversal
public static int index(File indexDir, File dataDir)throws
IOException {
//Listing 1.1 Indexer: traverses a file system and
indexes .txt files
//Create Lucene index in this directory Index files in this
directory
//Lucene in action: a sample application 13
if (!dataDir.exists() || !dataDir.isDirectory()) {
throw new IOException(dataDir+ " does not exist or is not a
directory");
}
IndexWriter writer = new IndexWriter(indexDir,new
StandardAnalyzer(), true);
writer.setUseCompoundFile(false);
indexDirectory(writer, dataDir);
int numIndexed = writer.docCount();
writer.optimize();
writer.close();
return numIndexed;
}
// recursive method that calls itself when it finds a directory
private static void indexDirectory(IndexWriter writer, File
dir)throws IOException {
File[] files = dir.listFiles();
for (int i = 0; i < files.length; i++) {
File f = files[i];
if (f.isDirectory()) {
indexDirectory(writer, f);
} else if (f.getName().endsWith(".txt")) {
indexFile(writer, f);
}
}
}
// method to actually index a file using Lucene
private static void indexFile(IndexWriter writer, File f)throws
IOException {
if (f.isHidden() || !f.exists() || !f.canRead()) {
return;
}
System.out.println("Indexing " + f.getCanonicalPath());
Document doc = new Document();
doc.add(Field.Text("contents", new FileReader(f)));
doc.add(Field.Keyword("filename", f.getCanonicalPath()));
writer.addDocument(doc);
}
}
Thanks...
|
| |
|
| |
 |
Manish Pandit

|
Posted: 2007-8-21 3:53:00 |
Top |
java-programmer >> database search using Lucene
On Aug 20, 12:30 pm, Amit Jain <email***@***.com> wrote:
> Hi,
>
> I am getting compile time error symbol not found on line
> doc.add(Field.Text("contents", new FileReader(f)));
> doc.add(Field.Keyword("filename", f.getCanonicalPath()));
> of method indexFile(IndexWriter writer, File f)
>
> when i look into class Field i didn't found any thing about Text and
> Keyword symbol.
>
> what i have to do to resolve above compile time error...
>
> /**
> *
> */
>
> import java.sql.*;
> import java.io.*;
> import org.apache.lucene.index.*;
> import org.apache.lucene.analysis.standard.StandardAnalyzer;
> import org.apache.lucene.document.Document;
> import org.apache.lucene.document.Field;
> import org.apache.lucene.document.Field.*;
>
> /**
> * @author apurohit
> *
> */
> /**
> * This code was originally written for
> * Erik's Lucene intro java.net article
> */
> public class FileIndex {
> public static void main(String[] args) throws Exception {
>
> File indexDir = new File("fileindex");
> File dataDir = new File("txt_file");
>
> int numIndexed = index(indexDir, dataDir);
>
> }
>
> // open an index and start file directory traversal
> public static int index(File indexDir, File dataDir)throws
> IOException {
> //Listing 1.1 Indexer: traverses a file system and
> indexes .txt files
> //Create Lucene index in this directory Index files in this
> directory
> //Lucene in action: a sample application 13
> if (!dataDir.exists() || !dataDir.isDirectory()) {
> throw new IOException(dataDir+ " does not exist or is not a
> directory");
> }
> IndexWriter writer = new IndexWriter(indexDir,new
> StandardAnalyzer(), true);
> writer.setUseCompoundFile(false);
> indexDirectory(writer, dataDir);
> int numIndexed = writer.docCount();
> writer.optimize();
> writer.close();
> return numIndexed;
> }
>
> // recursive method that calls itself when it finds a directory
> private static void indexDirectory(IndexWriter writer, File
> dir)throws IOException {
> File[] files = dir.listFiles();
> for (int i = 0; i < files.length; i++) {
> File f = files[i];
> if (f.isDirectory()) {
> indexDirectory(writer, f);
> } else if (f.getName().endsWith(".txt")) {
> indexFile(writer, f);
> }
> }
> }
>
> // method to actually index a file using Lucene
> private static void indexFile(IndexWriter writer, File f)throws
> IOException {
> if (f.isHidden() || !f.exists() || !f.canRead()) {
> return;
> }
> System.out.println("Indexing " + f.getCanonicalPath());
> Document doc = new Document();
> doc.add(Field.Text("contents", new FileReader(f)));
> doc.add(Field.Keyword("filename", f.getCanonicalPath()));
>
> writer.addDocument(doc);
> }
>
> }
>
> Thanks...
You are using an older API on a newer version of lucene (2.2). There
is no Field.Keyword and Field.Text anymore. This has been replaced
with Field.Index, Field.Store and Field.TermVector APIs in newer
lucene. Look for examples to upgrade to new API, or download an older
lucene (1.4.x).
-cheers,
Manish
|
| |
|
| |
 |
Amit Jain

|
Posted: 2007-8-21 3:57:00 |
Top |
java-programmer >> database search using Lucene
Ok
Thanks for your reply...
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- Any Source Code or Web site demonstrate the effect of gridwidth and gridheigh of GridBaglayoutDear all,
I want to make clear how the outlook of Gridbaglayout will
change according to different value of gridwidth and gridheight of
GridBagConstraints. Please suggest some source code for me so that I
can modify the source code of the value of gridheight and gridwidth,
thus I can find out the change of the outlook according to different
value of gridheight and gridwidth. Or please suggest some website for
me to investigate about the gridwidth and gridheight of
GridBagConstraints.
Thanks.
- 2
- Accessing a method inside of an object that is stored in a vector...I have been trying to post to .help all day but nothing is going
through. Will try it here and hope it does....
I am trying to access a getData() method that simply returns a stored
integer value from an object that is stored in a vector. I have tried
to do this but cannot get the notation correct. I tried google groups
and the only thing I got from there was to pull the object from the
vector into a temperary object. That didnt work.
So, here is the code I have so far of making the temp object and
making sure it is actually pulling one out. I still connot figure out
how to access the getData() method.
Any hints are appreciated.
import java.util.Vector;
public class StackUser
{
public static void main(String argv[])
{
Vector vector = new Vector();
for (int i = 0; i < 100; i++)
vector.add(i, new StackNode());
System.out.println(vector.get(0));
Object tobj = vector.get(0);
System.out.println(tobj);
}
}
public class StackNode
{
private int value = 0;
public StackNode()
{
value = (int)(Math.random());
}
public int getData()
{
return value;
}
}
- 3
- Java applets and client-side ssl certificates?Applet Gurus,
Is anybody out there doing Java applets and client-side ssl certificates?
When I turn the requirement on in Apache, I get handshake failure errors
when the applet tries to load. Certificates are installed in the web
browser for the user's html browsing.
Some of our customers are on locked down machines that don't allow
"installation of software" but they jave jre 1.4.2 and Java Web Start.
Considering using Java Network Launch Protocol (JNLP) or some other kind
of applet based install but I think this would require a signed applet.
This, in turn, would require a certificate to be installed beforehand
(to validate the signed jar). Since our certs are all done in-house,
I'm in a chicken/egg situation. All certificates are issued by an
internal CA but are not easy to get for various reasons.
Is there an easy way to mass-install certificates (to keystores) in a
secure way without touching all the workstations?
The applet/client-side certificates present four problems as I see it:
1 handling the user's certificate securely
2 Maintainig the internal CA and root certs
3 Excessive prompting for multiple passwords to keystores
4 Keystore security (Bouncy Castle libs are 1MB)
Does anyone have any advice to give?
Thanks
Chuck
- 4
- [OT] Any way to see if a website is up in an automated way?I am looking for a tool or technique that can automatically check to see if
a specific website is up - say twice a day - and then send me an email if it
isn't. I do not want to have to manually check myself.
Does anyone know of a way to do this?
I have no money to spend on this so if there is no free service that does
it, I'd be interested in how I can program this, preferably in Java. I
assume that my best bet would be Java application that I could schedule via
Windows XP scheduler but I can code applets and servlets too if that makes
more sense.
--
Rhino
- 5
- dynamic file download with *long* response time - How to show "Save As" early?I've got a Java servlet that delivers large database resultsets
transformed to Excel with the HSSF library. In some cases it takes
more than 15 minutes before transformation is done and content can be
delivered to the browser.
I want to show the "Save As" dialog as early as possible so the user
knows he's not lost and forgotten.
I already tried to send the response headers immediately after
receiving the request including content disposition and filename. Even
though the browser receives those headers it just won't trigger the
"Save As" dialog. This applies to both MS IE and Mozilla.
Any ideas appreciated.
- 6
- JUnit RemoteTestRunner ErrorHi. I was running a test suite under JUnit version 3.7.0 through
XDE/Eclipse version 2.0.1 and I got a null pointer error. When I
stepped through the program, I saw that the error occurs right when I
get a window telling me
that "org.eclipse.jdt.runner.RemoteTestRunner" type cannot be found.
Do I need this type? It does not seem to be in the junit.jar file.
Thanks for any info,
Ken
- 7
- poi hssf getCellStyle problemhey there,
i have a big problem with those cellstyles. i want to add background
color to some cells, but apparently i just can "change" cell styles
from cells which already "have one".
for better understanding of my problem, here's the code:
for ( int i = 0; i <= rowcount; i++ ) {
for (int j = 0; j <= colcount; j++) {
HSSFRow row = s1.getRow((short)i);
if (row != null) {
HSSFCell cell = row.getCell((short)j);
if (cell != null) {
HSSFCellStyle style = cell.getCellStyle();
style.setFont(font);
style.setWrapText(true);
style.setFillForegroundColor(colorIndex);
if ( (j%4== 0) && (colorIndex ==
HSSFColor.LIGHT_CORNFLOWER_BLUE.index) ) {
colorIndex = HSSFColor.LEMON_CHIFFON.index;
}
else if ( (j%4== 0) && (colorIndex ==
HSSFColor.LEMON_CHIFFON.index) ) {
colorIndex =
HSSFColor.LIGHT_CORNFLOWER_BLUE.index;
}
}
}
}
}
}
this piece of code just works for cells, which already have attributes
in their cell styles like background color and border. cells which
just have a border and no color won't get the instructed color...
does anybody know what to do? is the method cell.getCellStyle() not
the best option in this case?
best regards and thx in advance,
manuela
- 8
- JTabbedPane selection changesHello,
I couldn't find what would be the was to go to detect changes in a
JTabbedPane's selection...?
Can anyone give a hint please?
Karsten
- 9
- Kill a thread automaticallyHi,
If I have a class that runs a thread and no reference points to it, the
gc won't finalize the class because the thread is still running -> so
stopping the thread in the finalize() method won't work. Afaik this is
also true for daemon threads.
Is it possible to stop a thread automatically when there are no
references left? In my case it does not matter if the thread is
gracefully interrupted or just killed and whiped out.
greets,
-adi
- 10
- java tablesI'm writing an API and i'd like some help testing it.
The API is designed to allow developers to create feature rich tables both
server and client side.
- 11
- Detecting compiler version at runtimeThis is a multipart message in MIME format.
Does anyone know if there is a way to determine which version of the
compiler was used. That is, at runtime - using 1.4.x - finding
out if the class/jar was compiled with 1.3.x?
Thanks
<br><font size=1 face="sans-serif">Does anyone know if there is a way to determine which version of the compiler was used. That is, at runtime - using 1.4.x - finding</font>
<br><font size=1 face="sans-serif">out if the class/jar was compiled with 1.3.x?</font>
<br>
<br><font size=1 face="sans-serif">Thanks</font>
<br>
<br>
- 12
- Spring Framework for Java/J2EE/.NET Application development...
Hello all
I'm very pleased to announce the launch of www.SpringHub.com : a
one-stop information resource dedicated to the Spring Framework for
Java/J2EE/.NET application development.
SpringHub.com provides free, easy and fast access to hundreds of Spring
Framework resources organized in several categories and sub-categories:
- Spring Quick Start (Spring Framework Project, Spring Reference
Documentation, Spring Terminology, Spring Tutorials, Sample Book
Chapters)
- Spring InfoSources (Spring Articles, Spring Presentations, Spring
Blogs, Spring Wikis, Spring Interviews, Spring News)
- Spring Products (Spring Related Projects, Spring Libraries/Plugins,
Spring Tools, Spring Books, Miscellaneous)
- Spring Services (Spring Consulting, Spring Trainings, Spring Courses,
Spring Jobs)
- Spring Usage (Sample Applications/Code, Real-World Usage)
- Community Support (Spring Forums, Spring Mailing Lists, Spring User
Groups, Spring FAQs)
- Related Frameworks (Meta-Frameworks, IoC Frameworks, AOP Frameworks,
Front-End, Business Logic, Back-End, RIA Frameworks, Testing
Frameworks)
- Related Resources (Sun Official Resources, Java IDEs, Open Source
Stacks, Web Servers, Web Containers, Application Servers,View
Technologies, Remoting and Web Services)
With your feedback and URL submissions, SpringHub.com will evolve to
better serve you and the fast growing Spring Framework community.
Regards,
Slim Baltagi
J2EE Consultant
Chicago, USA
http://www.SpringHub.com
- 13
- Fake Odm Watches Unpretentious Cheap - Odm Watches Unpretentious Watch FakeFake Odm Watches Unpretentious Cheap - Odm Watches Unpretentious Watch
Fake
Fake Watches Home : http://www.watchesprice.net/
Fake Odm Brands : http://www.watchesprice.net/Odm-Watches.html
Fake Odm Watches Unpretentious : http://www.watchesprice.net/Odm-Watches-Unpretentious-Watches.html
Fake Odm Watches Unpretentious --- We are glad to offer you the best
Odm Watches Unpretentious Fake at a very moderate price. All these
timepieces are very bright and in style, select one for yourself or
for your beloved person.
Fake Odm Watches Unpretentious, full lines of this brand you can find
at our store, we offer wide range of brand name watch Fakes, these
fake watches are copied in high quality, yet in reasonable price.
Odm Watches Unpretentious All Products :
ODM Men's Watches Unpretentious SU23-3 - AA :
http://www.watchesprice.net/ODM-Mens-Watches-Unpretentious-SU23-3-AA-11713.html
ODM Men's Watches Unpretentious SU23A-6 :
http://www.watchesprice.net/ODM-Mens-Watches-Unpretentious-SU23A-6-11714.html
Odm Su23-4 Unpretentious Ll Mens Watch :
http://www.watchesprice.net/Odm-Su23-4-Unpretentious-Ll-Mens-Watch-11715.html
Odm Su23a-1 Unpretentious Ll Mens Watch :
http://www.watchesprice.net/Odm-Su23a-1-Unpretentious-Ll-Mens-Watch-11716.html
Odm Su23a-2 Unpretentious Ll Mens Watch :
http://www.watchesprice.net/Odm-Su23a-2-Unpretentious-Ll-Mens-Watch-11717.html
Odm Su23a-5 Unpretentious Ll Mens Watch :
http://www.watchesprice.net/Odm-Su23a-5-Unpretentious-Ll-Mens-Watch-11718.html
Odm Su53-1 Unpretentious 3 Mens Watch :
http://www.watchesprice.net/Odm-Su53-1-Unpretentious-3-Mens-Watch-11719.html
Odm Su53-2 Unpretentious 3 Mens Watch :
http://www.watchesprice.net/Odm-Su53-2-Unpretentious-3-Mens-Watch-11720.html
ODM Men's Watches Unerring III SU53-3 :
http://www.watchesprice.net/ODM-Mens-Watches-Unerring-III-SU53-3-11721.html
The Same Odm
Odm Never Too Late To Action : http://www.watchesprice.net/Odm-Never-Too-Late-To-Action-Watches.html
Odm Watches 3 Touch : http://www.watchesprice.net/Odm-Watches-3-Touch-Watches.html
Odm Watches Adventurous : http://www.watchesprice.net/Odm-Watches-Adventurous-Watches.html
Odm Watches Born for Clubbing : http://www.watchesprice.net/Odm-Watches-Born-for-Clubbing-Watches.html
Odm Watches Camouflage : http://www.watchesprice.net/Odm-Watches-Camouflage-Watches.html
Odm Watches Dragon : http://www.watchesprice.net/Odm-Watches-Dragon-Watches.html
Odm Watches Forever Lolita : http://www.watchesprice.net/Odm-Watches-Forever-Lolita-Watches.html
Odm Watches Link : http://www.watchesprice.net/Odm-Watches-Link-Watches.html
Odm Watches Luxury : http://www.watchesprice.net/Odm-Watches-Luxury-Watches.html
Odm Watches Mr. Metallic : http://www.watchesprice.net/Odm-Watches-Mr-Metallic-Watches.html
Odm Watches Mysterious V : http://www.watchesprice.net/Odm-Watches-Mysterious-V-Watches.html
Odm Watches No Fear In Dark : http://www.watchesprice.net/Odm-Watches-No-Fear-In-Dark-Watches.html
Odm Watches Out : http://www.watchesprice.net/Odm-Watches-Out-Watches.html
Odm Watches Pixel : http://www.watchesprice.net/Odm-Watches-Pixel-Watches.html
Odm Watches Speed : http://www.watchesprice.net/Odm-Watches-Speed-Watches.html
Odm Watches Spin : http://www.watchesprice.net/Odm-Watches-Spin-Watches.html
Odm Watches Sport : http://www.watchesprice.net/Odm-Watches-Sport-Watches.html
Odm Watches Symbol : http://www.watchesprice.net/Odm-Watches-Symbol-Watches.html
Odm Watches To Be Cool : http://www.watchesprice.net/Odm-Watches-To-Be-Cool-Watches.html
Odm Watches To Be Young : http://www.watchesprice.net/Odm-Watches-To-Be-Young-Watches.html
Odm Watches Uncompromising : http://www.watchesprice.net/Odm-Watches-Uncompromising-Watches.html
Odm Watches Unerring II : http://www.watchesprice.net/Odm-Watches-Unerring-II-Watches.html
Odm Watches Unit : http://www.watchesprice.net/Odm-Watches-Unit-Watches.html
Odm Watches Unpretentious : http://www.watchesprice.net/Odm-Watches-Unpretentious-Watches.html
Odm Watches Urban Warriors United :
http://www.watchesprice.net/Odm-Watches-Urban-Warriors-United-Watches.html
Odm Watches We Will Rock You : http://www.watchesprice.net/Odm-Watches-We-Will-Rock-You-Watches.html
Odm Watches World Peace : http://www.watchesprice.net/Odm-Watches-World-Peace-Watches.html
Odm Watches Zen : http://www.watchesprice.net/Odm-Watches-Zen-Watches.html
Geneva print is made by the Geneva law in 1886. Geneva law intended
to protect the real production of watches in Geneva, so as to avoid
other inferior Odm Watches Unpretentious products marked with Geneva
made being sold. So far, it has been revised several times to meet
the changes of the times. The watches which comply with the standards
movement watches will be eligible for Geneva imprin, the print is
carved Marker in Geneva emblem of the 'hawks' and 'key'. Geneva law
requirment of each part of the movement should be to made in
accordance with established rules and regulations exactly, although
some parts may be purely decorative, but can fully reveal the watches
totally dependent on artificial completed. Odm Watches Unpretentious
For example, all acute angle must be cut into slope, further
polishing; and Cyclovirobuxine gear is decorated artificially and
polished with wood. The rule was made to remove all inferior products
to ensure each one watches are completed in the best crafsmanship and
materials. Today, this rule has become the guarantee of making watches
in highest crafsmanship. Early watches manufacturers to prove the
accuracy of its products usually have their Odm Watches Unpretentious
and clocks be identified by the official observatory , then all
Observatory in Europe, including London, Paris, Geneva watches
manufacturing center had such service. Later watches manufactures
slowly moved to Geneva, official Observatory in Geneva could not load
all the works. In order to promote their products, Switzerland
goverment set up a full-time official of the test center called Sw iss
O ffic ia lCh ron om e te r Te s tin gAu-th or ity (COSC), by Sw iss
Ca lib ra tion Se rv ice of th e Sw iss Fed e ra lMe tro logy Bu reau
(SCS) has proved its impartiality. Watches tested by the COSC called
CH RONOM ETER (The Table), Odm Watches Unpretentious every one of the
movement have independent code and supporting documents, on behalf of
certain of its accuracy. <br> In watches making craftsmanship,
Observatory watches can be said to be pursuing a not bad ever extreme
realm. Error of Mechanical watch a day is 15 seconds, the Observatory
watches particularly emphasize movement, material and craftsmanship,
error a day at -4 to +6 seconds and the quartz watch is strictly
controled in the + / -0. within two seconds.
- 14
- no applicationshi guys
ive installed the jdk on my xp system
it will run applets, but when i try to run
an application i get the following
message in the command prompt window
'Exception in thread "main" java.lang.NoClassDefFoundError:'
the same programs work fine on the collage system, so
it shouldn't be the code
please help
pat
- 15
- ports/83434: www/jakarta-tomcat ports give the wrong ownershipOld Synopsis: tomcat ports give the wrong ownership to their installed executables
New Synopsis: www/jakarta-tomcat ports give the wrong ownership to their installed executables
State-Changed-From-To: feedback->open
State-Changed-By: hq
State-Changed-When: Tue Oct 18 15:44:20 GMT 2005
State-Changed-Why:
Timeout
Responsible-Changed-From-To: freebsd-java->hq
Responsible-Changed-By: hq
Responsible-Changed-When: Tue Oct 18 15:44:20 GMT 2005
Responsible-Changed-Why:
I'll handle this.
This is the last improvement to be applied to www/jakarta-tomcat55 before we
merge back all recent improvements into other Tomcat ports.
http://www.freebsd.org/cgi/query-pr.cgi?pr=83434
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
|
|
|