macOS command Unable to access a.jar - macos

I have a jar called a.jar. When I execute it with java -jar a.jar everything works correctly. But when I create this .command file:
#!/bin/bash
java -jar a.jar
execute chmod u+x launch.command and run it by double clicking, the terminal window displays
Error: Unable to access jarfile a.jar

When you run a .command file, it executes in your ~ (user) directory, that is why it is not able to find your a.jar file. You need to give the path of your a.jar to execute it from your .command file.
#!/bin/bash
java -jar path-to-file/a.jar

If running this from Intelli J on a Mac, always add the path-to-file which in my case was the target directory. Navigating "into" the target directory and running java -jar test.jar was the problem for me. The correct way is;
java -jar target/test.jar

This can happen when your are connected via SSH and the machine user is not logged in or its locked. MAC OS does not allow to run java -jar commands and returns Error: Unable to access jarfile a.jar. In order to solve it, just do the user login first.

Related

How to run java application automatically when EC2 instance starts without having to run it manually with java -jar file_name-SNAPSHOT.jar?

I tried the following steps but when I access my application in the browser using the url link, it returns a blank page. Here is what I did:
Copy My jar file to /home/ec2-user/
cp myApp-0.0.1-SNAPSHOT.jar /home/ec2-user
Next, I opened the rc.local in the VI editor and appended myApp-0.0.1-SNAPSHOT.jar
vi /etc/rc.local
#
#
#
#
touch /var/lock/subsys/local
//Append the below command:
java -jar /home/ec2-user/myapp-0.0.1-SNAPSHOT.jar
/:wq
Give permission to the symlink by running the following command:
chmod +X /etc/rc.d/rc.local
So I stopped my ec2 instance and after a while, I started it again to see if I was able to test my endpoints without having to manually run my appl with java -jar myApp-0.0.1-SNAPSHOT.jar But it did not succeed. I was told this way of doing is now obsolete. I also tried to follow the following link but the file naming was not obvious to me so I messed up some steps and got to the same result: failed Please can anyone direct me? Thanks! I tried the following steps but when I access my application in the browser using the url link, it returns blank page.

Cant execute bat file via Jenkins

The following bat file is working when running this directly on the machine.
#ECHO OFF
echo Starting the Application ...
START "app" java -jar app-0.0.1.jar
When calling this file via Jenkins it's not working.
Any idea why?
Thank you

How to install & run colororacle?

ColorOracle is a free color blindness simulator for Window, Mac and Linux. It help to check an UI Color Design for the Color Vision Impaired people.
Its executable file is a .jar. How to install an run colorOracle ?
An alternative solution for the run part is to use Java -jaroption :
java -jar ./colorOracle/ColorOracle.jar
Excerpt from the man java page:
-jar
Execute a program encapsulated in a JAR file. The first argument is the
name of a JAR file instead of a startup class name.
[…./colorOracle/ColorOracle.jar].
See the Jar tool reference page
and the Jar trail of the Java Tutorial #
http://java.sun.com/docs/books/tutorial/jar for information about
working with Jar files and Jar-file manifests.
On linux, via terminal :
cd ./path/to/myfolder
mkdir colorOracle
curl -o ./colorOracle/ColorOracleJar.zip -C - http://colororacle.org/ColorOracleJar.zip
unzip -n ./colororacle/ColorOracleJar.zip -d ./colorOracle
chmod a+x ./colorOracle/ColorOracle.jar
./colorOracle/ColorOracle.jar
For other OS, see http://colororacle.org

Installing and starting the H2 database on Ubuntu

I would like to use the H2 database on Ubuntu 12.10, and went to the website and got the platform independent install file.
The installation instructions are quite literally, "To install the software, run the installer or unzip it to a directory of your choice."
I'm not a Linux novice, so I've used many of the usual install procedures before, but I have no idea what I am supposed to do here. There are no configure or makefiles that I can find, and the documentation doesn't mention anything, and there I can't find anything using google.
I don't know if I am missing something obvious. Can anybody help please?
A shell script to start the H2 server and browser GUI is included. I don't have Ubuntu right now, but the steps should be:
Download the H2 zip file (for example h2-2013-07-28.zip).
Open a terminal window
And then run:
cd <download directory>
unzip h2*.zip
cd h2/bin
chmod +x h2.sh
./h2.sh
This should start the H2 server tool and open a browser window that lets you connect to a database.
The content of the h2.sh script is relatively simple, it is:
#!/bin/sh
dir=$(dirname "$0")
java -cp "$dir/h2-1.3.173.jar:$H2DRIVERS:$CLASSPATH" org.h2.tools.Console "$#"
What you can also do is double click the h2*.jar file (if double click is configured to start java), or run this on a command line:
java -jar h2-1.3.173.jar
this bash script start the server:
#!/bin/bash
java -cp h2*.jar org.h2.tools.Server
you need the h2-version.jar in the current directory as well
Download h2 from here http://www.h2database.com/h2-2015-01-16.zip, then once the download has completed, unzip in home directory and run the following:
cd (directory path ).
cd h2/bin.
chmod +x h2.sh.
./h2.sh.
If you're using Maven to download h2 database, then try to find out where does it saves (~/.m2/repository/com/h2database/h2/.../h2-version.jar). Since h2 dependency has all downloaded for you, then you just doubleclick on jar file (the web browser should open h2 GUI or look for h2 icon on system tray). And yes, GUI is the same as Standalone package has.
Update: as long as icon displays on tray - h2 will be launched. To disable it - right mouse click -> Exit

Running JAR file on AIX via KornShell script

I run the following command on my AIX machine.
/usr/java6_64/jre/bin/java -jar myapp.jar
Then, things look fine. The JAR file connects to the database and does whatever it needs to do.
But I need to put this command (plus a few others) in a script.
So I created a KornShell (ksh) script file called "script.ksh" to do the above.
#!/bin/ksh
/usr/java6_64/jre/bin/java -jar myapp.jar
But it is giving me the following exception:
EXCEPTION: TerminateProcessException: Cannot connect to the database.
java.sql.SQLException: No suitable driver
Now, there is a "lib" folder in the same location as the JAR file and script.ksh file where the JDBC driver is located.
Is there something I am missing in the shell script? Like classpath? I tried setting the classpath in the script with
CLASSPATH=/home/path/to/lib/*.jar
But it still gave me the error. Looks like it can't find the driver. Any help?
Try exporting the CLASSPATH variable.

Resources