Running JAR file on AIX via KornShell script - shell

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.

Related

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 excute java file from remote desktop(mstsc)

I logged into my remote desktop location from cmd by mstsc command. Made some changes in java file and saved it. But I am not sure how can I execute the java file from remote location. Can someone help me out.
Thanks and Regards,
Sm.Aslam.
I assume that you mean an uncompiled .java file. In that case, it is as easy as typing the following in Command Prompt:
javac file.java
Note that this requires Java to be installed on the remote computer. If this is not the case, you will have to install it.
Regards,
Gabe

Kafka installation - classpath is empty

I try to install kafka on my windows(8), and it's not work.
I download kafka and extract it on c:\kafka after it i change the server.properties and zookeeper.properties.
I set in those file the logs path.
I even try to download an tun zookeper outside the kafka install but the zookeeper runing and the kafka not.
the Error that i get when i try to run this command is:
bin\windows\zookeeper-server-start.bat .config\zookeeper.properties
and this is the result:
Classpath is empty. Please build the project first e.g. by running 'gradlew jarAll'
The solutions is to Download the binary jar file.
go to config\server.properties and config\zookeeper.properties and change the folder. the new folder need to be write with / and not .
and after it you need to got the main folder and run the command:
bin\windows\zookeeper-server-start.bat config\zookeeper.properties
without the . before "config\zookeeper.properties"
I have provided the answer for the similar error here, check this out.
https://i-am-jabi.medium.com/fixing-classpath-is-empty-69288c1509a2
Here are the steps to resolve the issue:
Open kafka-run-class.bat file. You will find this in bin\windows folder of your confluent Kafka.
Search for “rem Classpath addition for core” in kafka-run-class.bat file. When you find it, it looks like below.
Now lets add the below snippet above the “rem Classpath addition for core” line in kafka-run-class.bat file.
rem classpath addition for LSB style path
if exist %BASE_DIR%\share\java\kafka\* (
call:concat %BASE_DIR%\share\java\kafka\*
)
After adding the above snippet, your file will look like this.
Now, when you run the bat files under windows folder, they will run fine without any issues. Here is the zookeeper start log after fixing the classpath error.

macOS command Unable to access a.jar

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.

Where is jython jar located in webspehere application server home directory

I want to write a CGI script for Jython for websphere application server task. The CGI script required shebang where in I need to give jython file path. I have WAS 8.5 and I couldnt fine the jython jar anywhere . where in Jython jar in WAS home directory.
Your cgi script would have to invoke jython scripts from wsadmin, as in the following example.
wsadmin -lang jython -f 'c:/temp/script/test1.py'
It would be best to call specific files from within a script, rather than just simply command line arguments. Keep in mind that each time you invoke wsadmin from within a script it will fire up a separate JVM, which can be very cpu intensive. So it is best to put most logic in external scripts and then call the few .py scripts separately from inside the cgi script.
wsadmin is located in
profiles/<profile_name>/bin
Rerefence:
Jython Infocenter Info

Resources