Why the jar file cannot be find in cygwin? - cygwin

I am new to sygwin, so I am probably doing something wrong.
Here is my shell script:
!/bin/sh
set [-x]
export myInstallDirectory='/cygdrive/c/cygwin64/usr/uTrace_ServerMachine'
echo "myInstallDirectory=" $myInstallDirectory
export JAVA_HOME=/cygdrive/c/Java_JDK_SE_8_u77_64_bit
echo "JAVA_HOME = " $JAVA_HOME
export PATH=$JAVA_HOME/bin:$PATH
echo "PATH =" $PATH
export CLASSPATH=$myInstallDirectory/bin/UtraceServer.jar:$CLASSPATH
echo "CLASSPATH=" $CLASSPATH
java -jar UtraceServer.jar
set [+x]
Here is what the log shows:
myInstallDirectory= /cygdrive/c/cygwin64/usr/uTrace_ServerMachine
JAVA_HOME = /cygdrive/c/Java_JDK_SE_8_u77_64_bit
PATH = /cygdrive/c/Java_JDK_SE_8_u77_64_bit
/bin:/usr/local/bin:/usr/bin:/cygdrive/c/windows/system32:/cygdrive/c/ProgramData/Oracle/Java/javapath:/cygdrive/c/Program Files/Intel/WiFi/bin:/cygdrive/c/Program Files/Common Files/Intel/WirelessCommon:/cygdrive/c/WINDOWS:/cygdrive/c/WinZip/WINZIP/WINZIP32.EXE:/cygdrive/c/Java_JDK_SE_8_u77_64_bit/bin:/cygdrive/c/Java_JDK_SE_8_u77_64_bit/lib/tools.jar:/cygdrive/c/Java_EE_SDK_7_u2/glassfish4/bin:/cygdrive/c/Java_EE_SDK_7_u2/glassfish4/glassfish/bin:/cygdrive/c/Java_EE_SDK_7_u2/glassfish4/glassfish/lib/javaee.jar:/cygdrive/c/IBM/Derby/db-derby-10.12.1.1-bin/lib/derbynet.jar:/cygdrive/c/IBM/Derby/db-derby-10.12.1.1-bin/lib/derbytools.jar:/cygdrive/c/IBM/Derby/db-derby-10.12.1.1-bin/lib/derbyoptionaltools.jar:/cygdrive/c/IBM/Derby/db-derby-10.12.1.1-bin/test/jakarta-oro-2.0.8.jar:/cygdrive/c/IBM/Derby/db-derby-10.12.1.1-bin/test/derbyTesting.jar:/cygdrive/c/IBM/Derby/db-derby-10.12.1.1-bin/lib/derbyrun.jar:/cygdrive/c/IBM/DB2_EX~1/java/db2java.zip:/cygdrive/c/IBM/DB2_EX~1/java/db2jcc.jar:/cygdrive/c/IBM/DB2_EX~1/java/sqlj.zip:/cygdrive/c/IBM/DB2_EX~1/java/db2jcc_license_cu.jar:/cygdrive/c/IBM/DB2_EX~1/bin:/cygdrive/c/IBM/DB2_EX~1/java/common.jar:/cygdrive/c/ORACLE/NetBeans 8.1/java/maven/bin:/cygdrive/c/Program Files (x86)/Skype/Phone:/cygdrive/c/Cygwin/bin:/cygdrive/c/Program Files/Microsoft Network Monitor 3:/cygdrive/c/My_Software_Development/Client_Monitoring/Client_Scripts
CLASSPATH= /cygdrive/c/cygwin64/usr/uTrace_ServerMachine
/bin/UtraceServer.jar:.;C:\Java_JDK_SE_8_u77_64_bit\lib\tools.jar;C:\Java_EE_SDK_7_u2\glassfish4\glassfish\lib\javaee.jar;C:\IBM\Derby\db-derby-10.12.1.1-bin\lib\derbynet.jar;C:\IBM\Derby\db-derby-10.12.1.1-bin\lib\derbytools.jar;C:\IBM\Derby\db-derby-10.12.1.1-bin\lib\derbyoptionaltools.jar;C:\IBM\Derby\db-derby-10.12.1.1-bin\test\jakarta-oro-2.0.8.jar;C:\IBM\Derby\db-derby-10.12.1.1-bin\test\derbyTesting.jar;C:\IBM\Derby\db-derby-10.12.1.1-bin\lib\derbyrun.jar;C:\IBM\DB2_EX~1\java\db2java.zip;C:\IBM\DB2_EX~1\java\db2jcc.jar;C:\IBM\DB2_EX~1\java\sqlj.zip;C:\IBM\DB2_EX~1\java\db2jcc_license_cu.jar;C:\IBM\DB2_EX~1\bin;C:\IBM\DB2_EX~1\java\common.jar
Error: Unable to access jarfile UtraceServer.jar
The jarfile UtraceServer.jar is located in /cygdrive/c/cygwin64/usr/uTrace_ServerMachine/bin/UtraceServer.jar
and as you can see it is in the CLASSPATH.
Appreciate any help.

Java is not a Cygwin application so it can not understand its
PATH nor the cygdrive suffix.
JAVA_HOME = /cygdrive/c/Java_JDK_SE_8_u77_64_bit
PATH = /cygdrive/c/Java_JDK_SE_8_u77_64_bit

As explained in How to run Java from Cygwin, you can use Cygwin paths in your script, but just before you call Java, you should convert them to Windows paths, for instance with cygpath -p:
!/bin/sh -x
export myInstallDirectory='/cygdrive/c/cygwin64/usr/uTrace_ServerMachine'
echo "myInstallDirectory = $myInstallDirectory"
export CLASSPATH="$myInstallDirectory/bin/UtraceServer.jar:$CLASSPATH"
echo "CLASSPATH = $CLASSPATH"
CLASSPATH="$(cygpath -pw "$CLASSPATH")"
echo "CLASSPATH (Windows) = $CLASSPATH"
java -jar UtraceServer.jar
(I've omitted the other paths from the script, because Java is clearly found.)
cygpath can (among others) convert a single path between POSIX and and different Windows formats, e.g. -w converts a path to a Windows path. With the addition of -p it treats its argument as a path list (separated by : for POSIX, by ; for Windows). See cygpath --help for the full info.
Important: when you use this in scripts, it is recommended always to use double quotes (as in the script above). Doing this consistently considerably reduces the risks for issues caused by (e.g.) spaces in path names.

Related

Bash PATH entries duplicated

I use fedora Linux, I manually installed .net core, java and add the path to the PATH
Today, I checked my PATH and the output below, as you can see, jdk, dotnet and gradle entries are all duplicated. can someone tell me how to get this resolved please
/opt/jdk/bin:/opt/jdk/bin:/home/xxx/.local/bin:/home/xxx/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/opt/gradle/bin:/opt/dotnet:/opt/gradle/bin:/opt/dotnet
For readability:
/opt/jdk/bin:
/opt/jdk/bin:
/home/xxx/.local/bin:
/home/xxx/bin:
/usr/local/bin:
/usr/local/sbin:
/usr/bin:
/usr/sbin:
/opt/gradle/bin:
/opt/dotnet:
/opt/gradle/bin:
/opt/dotnet
below are the entries I added to my .bashrc file
# Java path settings
export JAVA_HOME=/opt/jdk
PATH=$JAVA_HOME/bin:$PATH
# gradle building system
PATH=$PATH:/opt/gradle/bin
# Disable dotnet Telemetry
export DOTNET_CLI_TELEMETRY_OPTOUT=1
# Dotnet path settings
export DOTNET_ROOT=/opt/dotnet
PATH=$PATH:$DOTNET_ROOT
export PATH
The system part of setting files that modify the PATH are /etc/bashrc and /etc/profile, they both have below quoted code. is this caused the duplication? but when I read the comment, /etc/bashrc need to redo this becasue pathmunge is unset at the end of /etc/profile
pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
}
Can someone help me out?
Thanks
B
I kinda live with it.
but I solved this by using the if, below is my solution
if ! [[ "$PATH" =~ "$JAVA_HOME/bin:/opt/gradle/bin:$DOTNET_ROOT:" ]]
then
PATH="$JAVA_HOME/bin:/opt/gradle/bin:$DOTNET_ROOT:$PATH"
fi
export PATH

How to use Sass with NetBeans on Linux / macOS

I used to be able to install and use Sass with NetBeans 8 as described in the top answer on How to use SASS with Netbeans 8.0.1
Now, with the current version of Sass (1.14.1), installing is different. Basically just download and untar. That's done and I've pointed NetBeans to the correct location. But this current version of Sass won't run correctly from NetBeans:
"/opt/dart-sass/sass" "--cache-location"
"/home/jasper/.cache/netbeans/8.2/sass-compiler"
"path_to_my.scss" "path_to_my.css"
Could not find an option named "cache-location".
This error is also covered by Sass output error in Netbeans 8.2 where they are using Windows.
I tried to add the cache location parameter (similar to the solution for Windows) to this line in the sass file:
exec "$path/src/dart" --no-preview-dart-2 "-Dversion=1.14.1" "$path/src/sass.dart.snapshot" "$#"
but I could not get it working (same error keeps appearing).
Anybody any ideas on how to get Sass 1.14.1 working from NetBeans 8.2 on Linux (Ubuntu)?
The issue is that --cache-location is no longer supported and should be removed. All of the original parameters are used by "$#". To remove the first two parameters, you should be able to use "${#:3}" (see Process all arguments except the first one (in a bash script)), but somehow that resulted into a "Bad substitution" error for me. So I opted to use shift 2 to remove them:
#!/bin/sh
# Copyright 2016 Google Inc. Use of this source code is governed by an MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.
# This script drives the standalone Sass package, which bundles together a Dart
# executable and a snapshot of Sass. It can be created with `pub run grinder
# package`.
follow_links() {
file="$1"
while [ -h "$file" ]; do
# On Mac OS, readlink -f doesn't work.
file="$(readlink "$file")"
done
echo "$file"
}
# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
path=`dirname "$(follow_links "$0")"`
shift 2
exec "$path/src/dart" --no-preview-dart-2 "-Dversion=1.14.1" "$path/src/sass.dart.snapshot" "${#}"
Make sure to keep the original file and create a copy to only be used with NetBeans and make the change there.
macOS (Home Brew)
If you are looking for the Dart Sass install location (after installing it with Home Brew), it is located here:
/usr/local/Cellar/sass/{version}/bin
macOS (node.js)
When using node.js, you will run into the "env: node: No such file or directory" issue.
To work around that I created (make sure you make it executable (chmod a+x)):
/usr/local/lib/node_modules/sass/sass_nb.sh
and added:
#!/bin/zsh
export PATH="$PATH:"/usr/local/bin/
shift 3
sass ${#}
NetBeans 11+
On NetBeans 11 and 12 I had to use shift 3 instead of shift 2.
My response is based heavily on Jasper de Vries'one:
It seems that Netbeans simply adds some additional parameters that are no longer supported by sass compiler.
In my case the complete command issued by Netbeans was:
"/home/alex/tools/dart-sass/sass" "--cache-location" "/home/alex/snap/netbeans/common/cache/12.0/sass-compiler" "--debug-info" "/home/alex/projects/alexgheorghiu.com/web/aaa.scss" "/home/alex/projects/alexgheorghiu.com/web/aaa.css"
So the first 3 parameters
"--cache-location" "/home/alex/snap/netbeans/common/cache/12.0/sass-compiler" "--debug-info"
must be "deleted" or ignored.
So you need to either alter the sass file or make a copy of it (safest way)
and add
shift 3
instruction.
So if you start from original version like:
#!/bin/sh
# This script drives the standalone dart-sass package, which bundles together a
# Dart executable and a snapshot of dart-sass.
follow_links() {
file="$1"
while [ -h "$file" ]; do
# On Mac OS, readlink -f doesn't work.
file="$(readlink "$file")"
done
echo "$file"
}
# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
path=`dirname "$(follow_links "$0")"`
exec "$path/src/dart" "$path/src/sass.snapshot" "$#"
You need to end up with something like:
#!/bin/sh
# This script drives the standalone dart-sass package, which bundles together a
# Dart executable and a snapshot of dart-sass.
follow_links() {
file="$1"
while [ -h "$file" ]; do
# On Mac OS, readlink -f doesn't work.
file="$(readlink "$file")"
done
echo "$file"
}
# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
path=`dirname "$(follow_links "$0")"`
shift 3
exec "$path/src/dart" "$path/src/sass.snapshot" "$#"
An interesting aspect is that this bug is known by Netbeans developers (See: Could not find an option named "cache-location") but I was not able to achieve that because under my Xubuntu 18 the Netbeans is a "snap" and therefore it's netbeans.conf file is read only.
But in case you CAN modify that file it might be a cleaner solution.

Will ailas be dropped in xterm after Linux login?

I'm using tcsh in red hat with a XFCE client. I want to make some setting in my .cshrc be execute only one time. I'm using the following command but it seems strange to me. The LOAD_SETTING env was reported as set when I start a xterm but the alias in the setting cannot be found. It seems my .cshrc was sourced at login time (I got the LOAD_SETTING environment variable set ) but some setting (at least alias) are not inherited. My question is which setting will be loaded and which will be lost in the terminal when I just start the terminal just after login?
I tried to change 'setenv LOAD_SETTING 3' to 'set LOAD_SETTING=3' and it seems works as expected: setting will be loaded when I start the terminal at first time but I just worried about the NOT environment variable is not safe enough as I'm trying to avoid SGE source my .cshrc for multi times.
if ! $?LOAD_SETTING then
echo "loading "`pwd`"/project_setting.csh"
source /project/project_setup
#force useful path order
set path = (/tools/bin/x86_64/ /tools/cad/bin /sf/tools/cad/scripts /oge/sfgrid/6.2u5p1/wrapper /oge/sfgrid/6.2u5p1/bin/lx26-amd64 . /bin /sbin /usr/bin /usr/sbin /sf/tools/bin /sf/tools/cad/wrapper/bin $path)
#delete repeated path
set path=(`echo $path | perl -e 'print join(" ", grep { not $seen{$_}++ } split(/ /, scalar <>))'`)
alias greg 'set ret=`find_tot` && $ret/bin/greg'
setenv LOAD_SETTING 3
exit 1
else
echo "project_setting.csh has already been loaded, abort to load it again!"
exit 1
endif

Setting up environment variable in linux

While installing UIMA I got this steps in readme file
* Set JAVA_HOME to the directory of your JRE installation you would like to use for UIMA.
* Set UIMA_HOME to the apache-uima directory of your unpacked Apache UIMA distribution
* Append UIMA_HOME/bin to your PATH
* Please run the script UIMA_HOME/bin/adjustExamplePaths.bat (or .sh), to update
paths in the examples based on the actual UIMA_HOME directory path.
This script runs a Java program;
you must either have java in your PATH or set the environment variable JAVA_HOME to a
suitable JRE.
I opened /etc/environment and perfomed this changes:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/UIMA_HOME/bin"
JAVA_HOME="/usr/lib/jvm/java-7-openjdk-i386"
UIMA_HOME="/root/Desktop/karim/software/UIMA/UIMA_SDK_1.4.5"
after that executed:
UIMA/UIMA_SDK_1.4.5/bin# ./documentAnalyzer.sh
which gave this error:
./documentAnalyzer.sh: 2: .: Can't open /bin/setUimaClassPath.sh
documentAnalyzer.sh code :
#!/bin/sh
. "$UIMA_HOME/bin/setUimaClassPath.sh"
if [ "$JAVA_HOME" = "" ];
then
JAVA_HOME=$UIMA_HOME/java/jre
fi
"$JAVA_HOME/bin/java" -cp "$UIMA_CLASSPATH" -Xms128M -Xmx900M "-Duima.home=$UIMA_HOME" "-Duima.datapath=$UIMA_DATAPATH" -DVNS_HOST=$VNS_HOST -DVNS_PORT=$VNS_PORT "-Djava.util.logging.config.file=$UIMA_HOME/Logger.properties" com.ibm.uima.reference_impl.application.docanalyzer.DocumentAnalyzer
What is the mistake here? I guess I set environment variable correctly
I think the answers given about adding the $ to the variable UIMA_HOME in your PATH variable are correct, but, I think you are also lacking the EXPORT command for your variables.
Look, after you set their values, you should also writhe this in /etc/environment:
export UIMA_HOME
export JAVA_HOME
export PATH
That way, you would be able to use them later (always remember to fix the PATH variable with the $UIMA_HOME as well).
If this does not work, try rebooting your computer after setting the variables as I said.
In the case that does not work either, try repeating the process and in a console (after doing everythin all over again) try using the following command:
source /etc/environment
Fianlly, if that does not work, try setting the variables in the file called /etc/profile (do the same process: setting the varialbes and exporting them), and this should work.
The order of variable assignments in your /etc/environment is wrong; in order to use $UIMA_HOME in the PATH=..., you have to define UIMA_HOME afore, e. g.
UIMA_HOME="/root/Desktop/karim/software/UIMA/UIMA_SDK_1.4.5"
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$UIMA_HOME/bin"
JAVA_HOME="/usr/lib/jvm/java-7-openjdk-i386"

How to compile Jigsaw http server on Linux?

I download the Jigsaw server source from w3c website, http://www.w3.org/Jigsaw/. I followed its instruction http://www.w3.org/Jigsaw/Doc/Programmer/compile.html, but still can not compile it on my linux. What does it mean to update your CLASSPATH to compile Jigsaw and use the new compiled classes? How could I set my classpath?
Plz give me some help.
Thanks.
It means you need to set the $CLASSPATH environment variable. I haven't looked at Jigsaw, but if you wanted to set your $CLASSPATH to include all the jar files within a directory (for example one that contains all the Jigsaw compiled jars) then you can use this script fragment:
CLASSPATH=""
for j in $(find /path/to/jigsaw/lib -name \*.jar)
do
if [ ! -z "$CLASSPATH" ]; then CLASSPATH="$CLASSPATH:"; fi
CLASSPATH="$CLASSPATH$j"
done
Now whenever you invoke the java command it will use the classes within /path/to/jigsaw/lib.
However this is not a good idea; better is to use the above technique to build an environment variable other than $CLASSPATH and pass that as the argument to the java -cp command line option:
cp=""
for j in $(find /path/to/jigsaw/lib -name \*.jar)
do
if [ ! -z "$cp" ]; then cp="$cp:"; fi
cp="$cp$j"
done
java -cp $cp ...

Resources