I am trying to run a java program on a text file got from this github page-
https://github.com/dbamman/book-nlp
This is the command it asks me to run -
./runjava novels/BookNLP -doc data/originalTexts/dickens.oliver.pg730.txt -printHTML -p data/output/dickens -tok data/tokens/dickens.oliver.tokens -f
I have followed the other instructions and run the file from the book-nlp-master folder (I have downloaded the zip file)
This command worked on Linux as far as I remember, but on Windows cmd it gives me this error-
'.' is not recognized as an internal or external command,
operable program or batch file.
If i switch the slashes as they are given in windows, it gives me -
'.\runjava' is not recognized as an internal or external command,
operable program or batch file.
How do I fix this. I ran this on Linux and it worked for me, but I don't remember what I did.
P.S. running 'runjava' gave the same error.
If you want to use Bash script with Windows, I suggest you use Git Bash. Git Bash is provided with Git installation for Windows.
Git : https://git-scm.com/downloads
You use Cygwin or Powershell which comes with the Github for Windows.
Related
I know there are lot of questions like this but i tried their solutions and nothing.
While i try to javac file.java i get 'javac' is not recognized as an internal or external command,
operable program or batch file. And java file 'java' is not recognized as an internal or external command,operable program or batch file.
My environment path is
(JAVA_HOME) C:\ProgramFIles\Java\jdk-15.0.2
and
(Path)
C:\ProgramFIles\Java\jdk-15.0.2\bin
...
:(
There is a typo in the path. Correct me if I'm wrong but on Windows
JAVA_HOME should be C:\Program Files\Java\jdk-15.0.2 and PATH should start with %JAVA_HOME%\bin;.
Next time, just copy-paste the path from Windows Explorer to avoid this.
Most probably you haven't installed java on your system. Try entering:
java --version
If you don't get a version number, install java from it's official site: https://www.java.com/en/download/
I'm attempting to execute Cygwin commands on Windows from a Java application. In cygwin's bin, I noticed some files are Application type (.exe) while others (like zcat and zless) have no extension and are just File type.
I've added the bin to the Windows PATH and seem to only be able to execute the .exe files from cmd. The code below works.
ProcessBuilder pb = new ProcessBuilder("cmd", "/c", "ls");
Process p = pb.start();
I want to use things like zcat and zless but they aren't executable and cmd complains that 'zcat' is not recognized as an internal or external command,
operable program or batch file.
If I manually change the file to .exe, I get a pop-up error saying zcat can't start or run due to incompatibility with 64-bit versions of Windows. I've installed the 64-bit version of cygwin (setup-x86_64). Why isn't all of cygwin's bin executable?
Most of the cygwin programs are NOT binary program but script one.
The command file can give you a description of the file type:
$ file zcat
zcat: POSIX shell script, ASCII text executable
while
$ file cat
cat: PE32+ executable (console) x86-64, for MS Windows
reading the first 5 rows of zcat
$ head -n 5 zcat
#!/bin/sh
# Uncompress files to standard output.
# Copyright (C) 2007, 2010-2016 Free Software Foundation, Inc.
we see on first row the #! that says that is a script to be executed by the
/bin/sh interpreter.
In other case we can have
$ head -n5 2to3
#!/usr/bin/python2.7.exe
import sys
from lib2to3.main import main
sys.exit(main("lib2to3.fixes"))
so 2to3 is a python 2.7 script
Nobody else has said this, so for anybody else looking for this ... if you need to run the "z..." commands from the cmd window AND you have the cygwin bin directory in your path, you can run them (yea, it's a bit klugy) using bash, as in
bash zcat file.gz
etc.
Or you can run them directly from the cygwin terminal.
FWIW I had to find the 'more' utilities and load them. For some reason they weren't in my initial set of packages I downloaded
I'm trying to execute a Java file I was given on Windows 10, inside of the Bash shell.
I open my command prompt. I enter bash.
I set
JAVA_CALL="C:/Program Files/Java/jdk1.8.0_192/jre/bin/java"
I try to execute the call, but to no luck. I read several threads on here and tried several things. I made sure my path includes both the Program Files x86 and the regular Program Files version of my JAVA.
I executed
sudo ln -s -f /mnt/c/Program\ Files/Java/jre1.8.0_192/jre/bin/java.exe /bin/java
To try and make a link to it. I cannot get it to wrong. It always tells me
-bash: C:/Program Files/Java/jdk1.8.0_192/jre/bin/java: No such file or directory
I am sure that file exists. Any ideas?
I am trying to compile java files using either the command prompt or Git-Bash (running Windows 7) but I am having no luck. I've researched this and followed the simple steps of checking the version of Java I have by running:
java -version
from the command line and I get "1.8.0_102".
So I went to my PATH variable and appended:
;C:\Program Files\Java\jdk1.8.0_102\bin
I have checked what seems like a thousand times and this is the proper directory, but when I run
javac
from the command line, I still get the error
'javac' is not recognized as an internal or external command, operable program or batch file.
Can anyone huide me in the right direction?
Try to set
JAVA_HOME system variable to C:\Progam Files\Java\jdk1.8.0_102;
and add %JAVA_HOME%\bin; to your CLASSPATH variable
Then restart the command line and try
It's official, dumbest mistake I've made yet. I wrote
Progam Files
not
Program Files
My java program was written on a windows machine and I am trying to get it installed and running on a Ubuntu 10.04 machine. I have created a .tar.gz file with myProgram.jar in it as well as 5 supporting library .jar files in a lib folder. Where do I put these files? Do I need to extract it on the Linux machine to a usr/bin folder? Does the shell script go inside the tar.gz? I have read that if you write the shell script on a windows machine you can have issues once you move it to the Linux machine, so I am writing the shell script on the Linux machine using gedit. I am just not sure what to do next.
So far in my script I have,
#!/bin/bash
java -jar myProgram.jar
I am going to try and extract the tar.gz file to the usr/bin directory and see if it runs.
Any suggestions or help would be greatly appreciated.
Thanks in advance,
Ray
Your question is quite "broad" :). I hope you find the following useful.
Do not extract the files to /usr/bin. See e.g. http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard on where and where not to put files on a *nix system.
Extract the jar's to e.g. /opt/yourProgram/*.
The shell script should be inside there too. Make sure its executable (i.e chmod 755 script.sh)
In your shell script add cd /opt/yourProgram to have the proper working directory for your program before you invoke java.
If you want this program to be started easily by everyone create a symbolic link in /usr/bin or better in /usr/local/bin pointing to your script. Do this as last step after everything else is working.
In your shell script you'll have to add the other jars to the classpath e.g.
java -cp lib/some.jar:lib/other.jar -jar myProgram.jar
or
java -cp lib/some.jar:lib/other.jar:myProgram.jar com.acme.ClassContainingMain
Recommended practice: Add set -e at the very beginning of your script
As you already mentioned it's considered harmful to edit a shell script using a windows editor. The reason is that the windows editor will encode line-breaks (i.e. you hit the Return key) differently. This will make bash puke :)
Im not too clear of what you are looking for.
The script that you have written should work absolutely fine if you have placed your script and myprogram.jar at the same level.
And also im not sure how your myprogram.jar is referring the dependent libraries. So can't comment on them. Best bet will be to place your script and all jars together and try running the script.