Python Java Pipe: dev/stdin file not found exception - java

Trying to use the python TweetNLP wrapper CMUTagger, but its throwing the following error:
java.io.FileNotFoundException: \dev\stdin (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at cmu.arktweetnlp.util.BasicFileIO.openFileToReadUTF8(BasicFileIO.java:50)
at cmu.arktweetnlp.RunTagger.runTagger(RunTagger.java:93)
at cmu.arktweetnlp.RunTagger.main(RunTagger.java:364)
Sep 17, 2014 10:22:45 AM cmu.arktweetnlp.util.BasicFileIO openFileToReadUTF8
SEVERE: Could not open file:/dev/stdin
Reinstalled the JDK instead of the JRE only. Didn't fix a thing. Not sure what to do as i cant even locate the dev folder in the java directory... halp =(
Executes java program fine if the cmd line call without python is 'sh', 'runTagger.sh', '--output-format', 'conll', [File with tweets to tag], but i need it to tag incoming stream of tweets from python via stdin =)
EDIT found the dev/stdin in CygWin and tried adding the paths 'c:...\cygwin' and 'c:...\cygwin\dev' but again nothing happened

I was stuck on this forever as well. I found a workaround for it.
You could use the following code:
import subprocess
p = subprocess.check_output('java -XX:ParallelGCThreads=2 -Xmx500m -jar ark-tweet-nlp-0.3.2.jar examples/example_tweets.txt')
this will give you output for running the example_tweets file through the tagger.

Related

Java's LingPipe error

I have no experience using java, i am trying to use lingpipe on windows (on linux everything worked perfectly) with command shell commands. But keep getting an error message.
these are the commands:
cd lingpipe\lingpipe-4.1.2-website\demos\generic\bin
cmd_pos_en_general_brown.bat -inFile=C:\lingpipe\test.txt -outFile=C:\lingpipe\testout.xml
as shown in this tutorial:
http://alias-i.com/lingpipe/web/demo-pos.html on the section of Part-of-Speech Demo via Shell Command.
The error message is:
C:\lingpipe\lingpipe-4.1.2-website\demos\generic\bin>set CLASS=com.aliasi.demo.demos.PosDemo
C:\lingpipe\lingpipe-4.1.2-website\demos\generic\bin>set ARGS="com.aliasi.tokenizer.IndoEuropeanTokenizerFactory,com.aliasi.sentences.IndoEuropeanSentenceModel,/models/pos-en-general-brown.HiddenMarkovModel,250000,250000,General English"
C:\lingpipe\lingpipe-4.1.2-website\demos\generic\bin>set CMD=com.aliasi.demo.framework.DemoCommand
C:\lingpipe\lingpipe-4.1.2-website\demos\generic\bin>set CP=../../;../lingpipe-demos.jar;../../../lingpipe-4.1.2.jar;../../lib/nekohtml-1.9.14.jar;../../lib/xercesImpl-2.9.1.jar;../../lib/xml-apis-2.9.1.jar
C:\lingpipe\lingpipe-4.1.2-website\demos\generic\bin>java -cp ../../;../lingpipe-demos.jar;../../../lingpipe-4.1.2.jar;../../lib/nekohtml-1.9.14.jar;../../lib/xercesImpl-2.9.1.jar;../../lib/xml-apis-2.9.1.jar com.aliasi.demo.framework.DemoCommand -demoConstructor=com.aliasi.demo.demos.PosDemo -demoConstructorArgs="com.aliasi.tokenizer.IndoEuropeanTokenizerFactory,com.aliasi.sentences.IndoEuropeanSentenceModel,/models/pos-en-general-brown.HiddenMarkovModel,250000,250000,General English" -inFile C:\lingpipe\test.txt -outFile C:\lingpipe\testout.xml
IOException processing inFile=*HAS_PROPERTY_VALUE* outFile=*HAS_PROPERTY_VALUE*
Exception msg=java.io.FileNotFoundException: *HAS_PROPERTY_VALUE* (The filename, directory name, or volume label syntax is incorrect)
java.io.FileNotFoundException: *HAS_PROPERTY_VALUE* (The filename, directory name, or volume label syntax is incorrect)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at com.aliasi.demo.framework.DemoCommand.processFile(DemoCommand.java:107)
at com.aliasi.demo.framework.DemoCommand.run(DemoCommand.java:80)
at com.aliasi.demo.framework.DemoCommand.main(DemoCommand.java:139)
ps: The inputfile already exists, the output file is supposed to be created automatically by the command.

How can I reset the path of FFMPEG in the VideoExport library in Processing?

Note: This question was originally titled "How can I reset the path of FFMPEG in Java?" but, as it has been pointed out in the comments and the answer, the issue is not with Java, so I've changed the title to make it easier to find for others with the same issue.
I accidentally set the path for FFMPEG to a different folder, and I can't change it back.
I'm using Processing (the library and its IDE) and the user-created Video Export library to capture and write to an mp4 video file. The library required FFMPEG, so I downloaded and installed it. After I installed it, I ran the code, and the library called Java to request the path of FFMPEG. I wrongly set the path to a different folder (which I eventually deleted), and immediately realized my mistake. I ran the code again to see if I could trigger the prompt again to correct the path.
The console response I received was: (I'm sure most of it doesn't have to do with the actual issue. However, I wanted to show all of it in case it somehow does.)
Oct 24, 2016 10:23:25 PM java.util.prefs.WindowsPreferences
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs
at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
java.io.IOException: Cannot run program
"C:...\Processing\Octree_Graphics\data\FFMPEG\ff-prompt.bat":
CreateProcess error=2, The system cannot find the file specified at
java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at
com.hamoid.VideoExport.startFfmpeg(Unknown Source) at
com.hamoid.VideoExport.initialize(Unknown Source) at
com.hamoid.VideoExport.saveFrame(Unknown Source) at
Octree_Graphics.draw(Octree_Graphics.java:90) at
processing.core.PApplet.handleDraw(PApplet.java:2399) at
processing.opengl.PSurfaceJOGL$DrawListener.display(PSurfaceJOGL.java:731)
at
jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:692)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:674)
at
jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:443)
at
jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293)
at
jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147)
at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:759) at
com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:81)
at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:452)
at
com.jogamp.opengl.util.FPSAnimator$MainTask.run(FPSAnimator.java:178)
at java.util.TimerThread.mainLoop(Timer.java:555) at
java.util.TimerThread.run(Timer.java:505) Caused by:
java.io.IOException: CreateProcess error=2, The system cannot find the
file specified at java.lang.ProcessImpl.create(Native Method) at
java.lang.ProcessImpl.(ProcessImpl.java:386) at
java.lang.ProcessImpl.start(ProcessImpl.java:137) at
java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ... 17 more
VideoExport error: Ffmpeg failed. Study
C:...\Processing\Octree_Graphics\basic.mp4.txt for more details.
I need to find a way to reset the path of FFMPEG that Java has. I have tried uninstalling and reinstalling the library, but I haven't tried Java (I don't want to mess with anything it has in its current state).
Firstly, from what I can tell, this is merely inside the library in Processing, not inside of Java itself.
I have found you can reset the ffmpeg directory by running the
".forgetFfmpegPath();" method on the VideoExport object. You only need to run it once then you can remove it.
Inside the Video Export docs the method has the description "Makes the library forget about where the ffmpeg binary was located."
You can find the documentation of the method in the VideoExport documentation, which can be found in the Processing IDE at "Help -> Libraries Reference -> Video Export". (Note the VideoExport library must be installed)
I understand this is two years old, but I am here for other people who have this issue.
I just had this issue and found this question, but there was no answer, so I am giving the answer I found worked.

How to get around the (Access is denied) to a folder that your java program is saving a file to?

I was wondering if someone could help me find a good resource to help me fix this issue. I'm trying to create/save a batch file in the startups folder. Here's the general path: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\startup_PMA_popup_check.bat
I've read a lot of things saying that I should simply elevate the privileges of my java program.
I read that if I was to make my jar file a windows executable, then the rights of the program are automatically elevated to admin privileges.
What you're seeing below is my jar turned into an exe and run. The error I got was the same error as the one I got from running my jar. I no longer think that the problem is simply giving my program admin privilege.
I performed a test outside of my program by going to this path and attempting to move a file into the folder. Assuming I'd have no issue "since I am root already", I went ahead expecting to get no prompts. What I got was a popup saying that I needed to confirm that I was Admin & to confirm that I wanted to put the batch file in the folder.
My question is how should I make my java program issue this prompt to the user or something so my program can continue & not crash like shown below??:
Exception in thread "main" java.io.FileNotFoundException:
C:\ProgramData\Microsoft\Windows\Start
Menu\Programs\StartUp\startup_PMA_popup_check.bat (Access is denied)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(Unknown Source)
at java.io.FileOutputStream.(Unknown Source)
at java.io.FileOutputStream.(Unknown Source)
at java.io.PrintWriter.(Unknown Source)
at java.io.PrintWriter.(Unknown Source)
at prioritymanagementassistant.Background.createBatchFile(Background.java:106)
at prioritymanagementassistant.Main.main(Main.java:930)
Thank You for your time,

How to see Aparapi generated OpenCL code

I am having Aparapi translating Java code to OpenCL. However I wonder how I can see the generated OpenCL code. The website says "by using adding -Dcom.amd.aparapi.enableShowGeneratedOpenCL=true to your command line when you start your JVM". Being new to this technology, I am not sure how exactly you can do this? Can anyone please help by elaborating the process?
Added part:
Thank you. But what should I do in case of hadoop? I am trying to generate the OpneCL code for a hadoop program that I am running this way:
hadoop jar .java
I have tried adding -Dcom.amd.aparapi.enableShowGeneratedOpenCL=true before and after jar word, both did not work. Here is what I got.
Exception in thread "main" java.io.IOException: Error opening job jar: -Dcom.amd.aparapi.enableShowGeneratedOpenCL=true
at org.apache.hadoop.util.RunJar.main(RunJar.java:90)
Caused by: java.io.FileNotFoundException: -Dcom.amd.aparapi.enableShowGeneratedOpenCL=true (No such file or directory)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:215)
at java.util.zip.ZipFile.(ZipFile.java:145)
at java.util.jar.JarFile.(JarFile.java:153)
at java.util.jar.JarFile.(JarFile.java:90)
at org.apache.hadoop.util.RunJar.main(RunJar.java:88)
Just add the property to the command line which you use to start java.
Specifically somewhere you have a command line like this
java -classpath yourpackage.YourApp
Just add the property like this
java -Dcom.amd.aparapi.enableShowGeneratedOpenCL=true -classpath yourpackage.YourApp

com4j on Windows 64 bit

I've downloaded the latest com4j jars and I'm trying to run through the most simple of their examples.
I'm on Windows 7 64 bit and using a 64 bit JVM.
When I run the command (from the com4j tutorial):
java -jar tlbimp.jar -o wsh -p test.wsh %WINDIR%\system32\wshom.ocx
I get:
Exception in thread "main" java.lang.UnsatisfiedLinkError: com4j-amd64.dll: %1 is
not a valid Win32 application
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at com4j.COM4J.loadNativeLibrary(COM4J.java:569)
at com4j.COM4J.<clinit>(COM4J.java:522)
at com4j.tlbimp.driver.Lib.getLibid(Lib.java:90)
at com4j.tlbimp.driver.Driver.addLib(Driver.java:38)
at com4j.tlbimp.driver.Main.doMain(Main.java:123)
at com4j.tlbimp.driver.Main.main(Main.java:56)
Exception in thread "Com4J shutdown hook" java.lang.NoClassDefFoundError: Could
not initialize class com4j.COM4J
at com4j.COM4J$3.run(COM4J.java:476)
The java code extracts "com4j-amd64.dll" next to the jar.
The latest version has just been released:
http://kohsuke.org/2012/04/27/com4j-updates/
https://github.com/kohsuke/com4j/downloads
Using this one solved all my problems.
You have two options:
Download and use the full latest version (located here:
https://github.com/kohsuke/com4j/downloads)
Extract the latest com4j-amd64.dll from the most recent version
Download the latest version (located here: https://github.com/kohsuke/com4j/downloads).
Open up the com4j.jar with your favorite zip utility (read 7zip)
Extract com4j.jar\com4j\com4j-x64.dll to the base directory of your application
(optional) Register the dll using REGSVR32 <path to dll>\com4j-x64.dll
I had a similar result at first. I found the com4j-amd64.dll that is produced by com4j is empty. The remedy is to extract the file from the com4j jar file, and put it in the relevant directory by manual action. Com4j will then not auto-produce the file since it is already there. So check if the file is empty as a first step -Carl

Categories

Resources