How to make the yuicompressor jar file a singleton, or globally accessible? - windows

I'd like to put the yuicompressor jar file in a single folder so that I can call
java -jar yuicompressor-2.4.2.jar ...
from anywhere on my system, with cygwin. For bash files I use I simply put them in a common folder, and added the folder's path to my windows user's PATH environment variable and the bash commands were found in cygwin.
when I echo $PATH I see the folder I put the yuicompressor jar into listed in the $PATH..
But when I try java -jar yuicompressor-x.y.z.jar myfile.js -o myfile-min.js (for example) I get the following error message:
Unable to access jarfile yuicompressor-2.4.2.jar
Even when I try providing an absolute path to the jarfile I get the same error message..
How can I do this?

The PATH environment variable is a list of directories the shell will search through in an attempt to run a command.
java.exe will not search the directories on the PATH environment variable to try and locate the archive you are attempting to run. So running java -jar yuicompressor-2.4.2.jar from any directory other than the one containing the archive would be expected to fail.
What is the full command you are attempting when providing an absolute path?

Related

MAVEN - Setting Path in Redhat so the maven commands can be run from anywhere

I have just installed Maven on Redhat, the apache-maven-3.3.9 is located in /root/, I ran the following command to set the path (JDK java home path already set and when I type $PATH the below path does show, along with when I type mvn --version):
export PATH=/root/apache-maven-3.3.9/bin:$PATH
The project I want to build with Maven is also in /root/ however, I cannot use the maven commands within the project or anywhere else except for /apache-maven-3.3.9/bin directory.
Any help would be much appreciated!
You need to add it to your ~/.profile file.
export PATH=$PATH:/root/apache-maven-3.3.9/bin
so that when you exit the terminal and start a new terminal instance path is not lost

install4j how to specify install dir on Windows Gradle

I have trouble using install4j on Windows for the project tripleA.
See source at: https://github.com/gaborbernat/triplea/blob/installer/build.gradle
I'm using the Gradle Plugin however I'm unable to specify the install 4j home directory.
If I try using absolute path that is 'C:/Program Files/install4j6' i get a normalization error as it gets translated to:
"C:/data/tripleA/'C:/Program Files/install4j6'"
what am I missing here? why is file('C:/Program Files/install4j6') referring to "C:/data/tripleA/'C:/Program Files/install4j6'"?
Now if I use a relative path it says the folder does not exists.
Thanks,
Due to your build.gradle, the path is retrieved from properties file. It seems, that this path in your properties is placed within single quotes, as 'C:/Program Files/install4j6', and your gradle script logic get the value with this quotes.
That is the reason, file() doesn't recognize it as absolute path and tries to parse it as relative. Here is some code, which reproduces your exception:
task testFile {
File ff = file('\'d:/test.xml\'')
println ff.absolutePath
}
This will cause an error
Could not normalize path for file 'D:\path\to\your\project\'d:\test.xml''
So, you should try to change the property, to make it a plain string without quotes.

How to represent directory of IzPack installer?

I'm using Maven and IzPack. I'm looking for a way to put a file into the directory of the installer file. In the install.xml I've got a file tag set with a targetdir of "." but that will only work if the installer is executed from that directory. If executed from a different directory, the file is put in the current working directory of the user instead.
Having checked IzPack documentation, there's a built-in variable for $INSTALL_PATH, but I need the path of the installer. There's no way to predict where this installer will be when executed so specifying a pre-set directory won't work. Trying to specify the local directory via Maven just gives the path to the POM.
Is there an undocumented variable that would do the job or something else I've overlooked?

Reference a path outside the project directory

learning Gradle, and I am running into an issue. I'd like to add the JAR files from the TomcatEE directory to the compilation classpath, and the tomcatEE directory lives outside the project hierarchy on the file system. For example, the tomcatEE directory is "C:/servers/tomcatee/". I want to define a property "tomcarDir" and then add tomcatDir + '/lib/' to the build path, but Gradle insists on appending the project directory to the start. How do I specify an absolute path like this?
I found my error. In my gradle.properties file, I had the path to the tomcat directory enclosed in single quotes. By removing them, Gradle started treating it as an absoolute file path.

Open jar file with cmd

I have a jar file named "adventure.jar". When you run it through the cmd with java -jar adventure.jar it works fine. However, I am testing opening the file on a new computer, and I am encountering a problem. This computer doesn't have the java command in the command prompt. It defiantly has Java installed, but maybe just not the JDK? Anyway, my goal is to make the jar file run from cmd when double clicked, without the need of commands (is that even possible?). The jar is already executable, but it doesn't execute from the command prompt like I need. Any help would be appreciated.
EDIT: If there is a way to do this through an exe or batch file I'd be fine with that, too.
Sounds like your PATH env. variable doesn't have Java in it. You can add it by following Oracle's tutorial
Adding Java to your PATH Environment variable.
Usually it's something like ;C:\Program Files\Java\jre7\bin
To your second question - yes it's possible.
Open up notepad, then type java -jar adventure.jar then save it as launch.bat or something. then you are able to double click that batch file, which will run your java archive.
Open command prompt
Go to the folde where jar file is located
Run
unzip test.jar
here test.jar is name of the jar file.
This command will unzip all the file into that folder
First, try start adventure.jar from Command Prompt. If that does not work, locate java.exe (on my computer, C:\Program Files\Java\jre7\bin) and either use the full path in Command Prompt, or add the path to the folder containing java.exe to your PATH environment variable. To add the path, click Start Menu, right-click Computer, click Properties, click Advanced System Settings, click Environment Variables, then find PATH under System Variables and click Edit, and add the path (example: add the following onto the end of PATH: ;C:\Program Files\Java\jre7\bin and don't forget the semicolon!)
Hope it helps.

Resources