I've seen other posts about this but I still couldn't get it to work.
http://snowball.tartarus.org/dist/libstemmer_java.tgz <<- this contains the java implementation of the porter2 algorithm.
What I did was extract the contents on my desktop (for easy access) and opened its .java file using Netbeans IDE. I ran it but it returned an error.
Netbeans doesn't read the other java files. Since all the java files are connected to each other, one error from javaX file produces error on javaY file and so on.
TestApp.java is the one which should be ran. But the following errors occur. See the screenshots.
Here are the screenshots:
http://img248.imageshack.us/img248/290/java1.jpg
http://img4.imageshack.us/img4/5196/java2l.jpg
http://img441.imageshack.us/img441/8625/java3i.jpg
I cannot see your images any longer. The ext folder will not compile because of 3 unreachable statements in frenchStemmer.java. They can easily be removed, or just delete the entire file if you are not using french.
case 13:
// (, line 155
// call RV, line 155
if (!r_RV())
{
return false;
}
// fail, line 155
// (, line 155
// <-, line 155
slice_from("ant");
return false;
break; <<<- remove this
I compiled and ran in the free Community Edition of Intellij, and also using the command line.
Related
I have 2 JAR files coming from an SDK that I have to use.
Generation problem
I succeeded in generating the first .pas file, but Java2OP fails to generate the second .pas I need, with the message
Access violation at address 0042AF4A dans the 'Java2OP.exe' module. Read at address 09D00000
Would this come from a common issue? There's no other hints about what causes the problem in the SDK .jar.
I'm using Java2OP located in C:\Program Files (x86)\Embarcadero\Studio\18.0\bin\converters\java2op, but I had to first use the solutions in Delphi 10.1 Berlin - Java2OP: class or interface expected before generating the 1st file.
Compilation problem
Anyway, I tried to generate a .hpp file from the generated .pas.
I don't know much about Delphi. Does the problem come from the SDK itself, or the generation of the .pas file?
1st issue solved
Java2OP included Androidapi.JNI.Java.Util
and not Androidapi.JNI.JavaUtil. I had to import Androidapi.JNI.JavaUtil myself, though it is present in the /Program Files(x86)/Embarcadero/... folders.
2nd issue
The same 4 compilation errors happen multiple times across the .pas file on parts using the word this.
Do I have to replace every use of this with self?
Errors
E2023 The function require a type of result : Line 4
E2147 The property 'this' doesn't exist in the base class : Line 5
E2029 ',' or ':' awaited but found 'read' identificator : Line 5
E2029 ',' or ':' awaited but found number : Line 5
[JavaSignature('com/hsm/barcode/DecoderConfigValues$SymbologyFlags')]
JDecoderConfigValues_SymbologyFlags = interface(JObject)
['{BCF30FD2-B650-433C-8A4E-8B638A508487}']
function _Getthis$0: JDecoderConfigValues; cdecl;
property this$0: JDecoderConfigValues read _Getthis$0;
end;
[JavaSignature('com/hsm/barcode/ExposureValues$ExposureSettingsMinMax')]
JExposureValues_ExposureSettingsMinMax = interface(JObject)
['{A576F85F-A021-475C-9741-06D92DBC205F}']
function _Getthis$0: JExposureValues; cdecl;
property this$0: JExposureValues read _Getthis$0;
end;
I have a tarball that I can't open using python:
>>> import tarfile
>>> tarfile.open('/tmp/bad.tar.gz')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "tarfile.py", line 1672, in open
raise ReadError("file could not be opened successfully")
tarfile.ReadError: file could not be opened successfully
but I'm able to extract the file with no problem on the command line.
$ tar -xzvf /tmp/bad.tar.gz
I've traced the python tarfile code, and there's a function "nti" where they're converting bytes. It gets to this line:
obj.uid = nti(buf[108:116])
and blows up. These bits (for the UID) coming through as eight spaces. Not sure where to go from here...
Honestly it looks like the bug is in tarfile.py's nti function:
n = int(nts(s) or "0", 8)
The fall-through logic (or "0") is not working because s is spaces, not None, so int() blows up.
I copied tarfile.py from /var/lib/python2.7/ and wrapped that particular line with a try/catch, which fixed me up:
try:
obj.uid = nti(buf[108:116])
except InvalidHeaderError:
obj.uid = 0
It's a hack solution, though. Really I'd prefer that the python folk took a look at it and fixed the "or "0" logic.
Update
Turns out the tarball was created by the maven-assembly-plugin in a Java 6 project that had just been upgraded to Java 7. The issue was resolved by upgrading the maven-assembly-plugin to 2.5.3.
When I try to compile the below Latex document from Java, my pdflatex run crashes:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\pagestyle{empty}
%
\tikzstyle{int}=[draw, fill=blue!20, minimum size=2em]
\tikzstyle{init} = [pin edge={to-,thin,black}]
\begin{tikzpicture}[node distance=2.5cm,auto,>=latex']
\node [int, pin={[init]above:$v_0$}] (a) {$\frac{1}{s}$};
\node (b) [left of=a,node distance=2cm, coordinate] {a};
\node [int, pin={[init]above:$p_0$}] (c) [right of=a] {$\frac{1}{s}$};
\node [coordinate] (end) [right of=c, node distance=2cm]{};
\path[->] (b) edge node {$a$} (a);
\path[->] (a) edge node {$v$} (c);
\draw[->] (c) edge node {$p$} (end) ;
\end{tikzpicture}
\end{document}
pdflatex doesn't just produce some error, but it simply freezes. The log file is cut off in the middle, even before an enclosing quotation mark is completed (but always at the same position, I think).
I use this Java command to execute pdflatex:
Runtime.getRuntime().exec(command);
p.waitFor();
The command executed is:
"C:\Program Files\MiKTeX 2.9\miktex\bin\x64\pdflatex.exe" -output-directory "C:\Eig\Lehre\Info2\ImagesTemp" "C:\Eig\Lehre\Info2\ImagesTemp\graph.tex"
Executing the command by hand in a command line works fine! Also, the Java execution works fine when I don't include tikz in the latex document. This seems quite strange to me - is there some bug or am I missing something?
I'm using Miktex 2.9 and Java 8 on Windows, I've tried it on different Windows versions.
This problem is probably caused by not capturing the output of the process. You need to read every byte written to standard out and standard error by the child process else the system buffer will fill up and the process will block when it next attempts to write something.
Here's a related question: Capturing stdout when calling Runtime.exec
Which points to http://www.javaworld.com/article/2071275/core-java/when-runtime-exec---won-t.html for more information.
I have been using the JavaImp.vim script for auto importing Java statements in VIM
But trying out different directories in the JavaImpPaths, I am still unable to make JavaImp parse the Java files in the source to make auto imports possible
this is how my .vimrc looks like
let g:JavaImpPaths = "~/Documents/android-sdks/sources/android-21/android/content/"
let g:JavaImpClassList = "~/.vim/JavaImp/JavaImp.txt"
let g:JavaImpJarCache = "~/.vim/JavaImp/cache/"
This is what I get running JIG in new Vim window
:JIG
Do you want to create the directory ~/.vim/JavaImp/cache/?
Searching in path (package): ~/Documents/android-sdks/sources/android-21/android
/content/ ()
Sorting the classes, this may take a while ...
Assuring uniqueness...
Error detected while processing function <SNR>10_JavaImpGenerate:
line 75:
E37: No write since last change (add ! to override)
Done. Found 1 classes (0 unique)
Press ENTER or type command to continue
It might be late, but if anyone else comes along this might help them...
I got it working with the following changes to the script:
line 181 from
close
to
close!
And lines 207/208 from
let l:javaList = glob(a:cpath . "/**/*.java", 1, 1)
let l:clssList = glob(a:cpath . "/**/*.class", 1, 1)
to
let l:javaList = split(glob(a:cpath . "/**/*.java"), "\n")
let l:clssList = split(glob(a:cpath . "/**/*.class"), "\n")
I'm trying to use Mozilla Rhino in my Java application for Android to evaluate some JavaScript. I am using Eclipse + ADT plugin.
First I tried simply downloading the Rhino .jar file from Mozilla's website and adding it to the project as a library in Eclipse. Eclipse recognised it fine and compiled the application. However, when running it I get an exception when calling Context.evaluateReader() (see below for stack trace).
Then I tried adding the Rhino source code as a separate Android project in Eclipse, marking it as a library and referencing it in my project, which was enough to get Eclipse to get it to compile, but led to the same error.
This is the stacktrace I get (java.lang.UnsupportedOperationException: can't load this type of class file)
Thread [<7> Thread-8] (Suspended (exception UnsupportedOperationException))
DefiningClassLoader(ClassLoader).defineClass(String, byte[], int, int, ProtectionDomain) line: 338
DefiningClassLoader.defineClass(String, byte[]) line: 62
Codegen.defineClass(Object, Object) line: 159
Codegen.createScriptObject(Object, Object) line: 114
Context.compileImpl(Scriptable, Reader, String, String, int, Object, boolean, Evaluator, ErrorReporter) line: 2440
Context.compileReader(Reader, String, int, Object) line: 1326
Context.compileReader(Scriptable, Reader, String, int, Object) line: 1298
Context.evaluateReader(Scriptable, Reader, String, int, Object) line: 1137
TimetableProcessor.evaluate(InputStream, String, String[]) line: 31
TimetableProcessor.processBasicData(InputStream, String) line: 58
TimetableProcessor.process(InputStream, String) line: 52
TimetableUpdater.update() line: 53
Main$1$1.run() line: 22
The bit of my code that hits the exception looks like this:
Context cx = Context.enter();
cx.setLanguageVersion(Context.VERSION_1_7);
Scriptable scope = cx.initStandardObjects();
try {
Object result = cx.evaluateReader(scope, new InputStreamReader(data), /* <<< exception here */
filename, 0, null);
} catch (IOException e) {
// ...
}
I also found this blog post which contains similar code and says it works. The author says he used a jar file from the Android Scripting site. The only jar file I found there was in rhino_extras_r3.zip. However, it doesn't contain .class files but rather a classes.dex file. When I added this as a library in Eclipse, it didn't recognise the classes it contains and thus failed to compile my project because of the missing references to Rhino classes.
Any help at all on how to get this to work is appreciated!
I finally got it to work. I should have paid more close attention to that blog post I linked.
If I add the line
cx.setOptimizationLevel(-1);
to disable optimisations, everything works perfectly.
An Android-compatible edition of rhino1_7R2.jar is available on the SL4A site, in the version control system. Here is a sample project that wraps up Rhino and BeanShell into an Android interpreter service.
I've written a library which allows to run Rhino on Android.
Advantages include:
Rhino can only run on optimization level -1. The library supports all levels.
The library supports the use of JavaAdapter, which is not possible with base Rhino.
Altough i did not benchmark this, it should give a performance increase. (Compiled code is faster than interpreted code)
https://github.com/F43nd1r/rhino-android