asadmin command doesn't work in ubuntu - java

I'm using Java EE with Glassfish.
I can't run asadmin command as well. I did the following, but output from terminal is:
No command 'asadmin' found, did you mean: Command 'amadmin' from package 'amanda-server' (universe) Command 'acsadmin' from package'ion' (universe) asadmin: command not found
I have Ubuntu 14.04 Trusty Tahr. I should be in bin directory of glassfish, so I'm in /opt/glassfish4/bin.
But always nothing happend, just error message above.

In Ubuntu and Linux in generál, you run commands from current directory like this: ./asadmin, ie. you must prepend ./ to make it explicit that you run a command I current directory. This is traditionally for some security reasons.

Try following command export PATH=/installationDirectory/glassfishName/bin:$PATH
In my case it was export PATH=/opt/glassfish4/bin:$PATH

The asadmin command needs to be read from glassfish bin directory when executing commands, hence you need to export the following in your environment variables.
On mac,
export PATH=/Users/macpro15/Downloads/glassfish5/bin:$PATH

I think you are creating the domain inside the default domain. You should make your own domain in the domains folder, and the run the following command in your terminal:
sh asadmin start-domain DOMAIN_NAME

Related

My java program runs in netbeans, but will not run in command or through the jar file. What am I doing wrong?

So, I am trying to run a program from jar files. It uses javaswing and has a gui.
The program runs fine in netbeans and in eclipse.
When I try to run it from the exported jar file it says this:
Unable To Install Java
There are errors in the following switches:
"C:\Users\CNC Department\Desktop\ValveConversion.jar";.
Check that the commands are valid and try again.[java installation not complete
Now, I also tried doing it from the command prompt. Here is what came up:
[cmd prompt attempt][1] [1]: https://i.stack.imgur.com/7reZ3.png
So, I reinstalled the java JDK, java SDK, netbeans and eclipse. The issue is still occurring in both command prompt and from running the jar file directly.
What am I doing incorrectly here? What do you recommend that I do to get this to run from a .jar file?
You need to set the java path
Open a cmd with elevated privileges and run this command to set the JAVA_HOME environment variable using setx command:
setx JAVA_HOME -m "C:\Program Files\Java\jdk-11.0.2"
Then restart the cmd and run java -version to check if it's all ok.
For reference setx command documentation
Or simply use the following snippet if you prefer to use java without setting the PATH variable:
"C:\Program Files\Java\jdk-11.0.2\bin\java" -jar "C:\Users\CNC Department\Desktop\ValveConversion.jar"

Failed to run a Java app with Git Bash

I downloaded SymmetricDS, a tool for Database replication and tried to run it on my Windows7 machine. The program can be launched from command line and it works with Windows Terminal. However I always prefer Git Bash for command line stuff. When I run command sym though, I got error:
Error: Could not find or load main class org.jumpmind.symmetric.SymmetricLauncher
This tool is written in Java. I have JDK 1.8 installed. Git Bash inherits all environmental variables including $PATH and $JAVA_HOME from Windows. But why is it complaining about not finding the class?
The sym command is really running the following command:
exec "$SYM_JAVA" $SYM_OPTIONS -cp "$CLASSPATH" org.jumpmind.symmetric.SymmetricLauncher "$#"
All the jars are located in lib under the root directory of the application. The classpath is defined in a sym.service.conf inside conf directory:
# Java Classpath
wrapper.java.classpath.1=patches
wrapper.java.classpath.2=patches/*
wrapper.java.classpath.3=lib/*.jar
wrapper.java.classpath.4=web/WEB-INF/lib/*.jar
# Application main class and arguments
wrapper.app.parameter.1=org.jumpmind.symmetric.SymmetricLauncher
I added echo $CLASSPATH right before the exec to print out the class path and it did seem to get all of them right:
/c/Users/dnj0109/Apps/symmetric-server-3.8.29/patches:
/c/Users/dnj0109/Apps/symmetric-server-3.8.29/patches/*:
/c/Users/dnj0109/Apps/symmetric-server-3.8.29/lib/*:
/c/Users/dnj0109/Apps/symmetric-server-3.8.29/web/WEB-INF/lib/*
That could be related to this thread:
On Windows, the path separator is a semicolon (';' instead of ':').
Don't ask why. Traditionally, the semicolon is interpreted by the Bash as
the command separator, so you'll have to escape it:
$ java -cp lib/clojure-1.1.0.jar\;lib/clojure-contrib-1.1.0.jar
If you wonder why it works with PATH: MSys has special handling routines
for that.
Another reason that a java app may run in a Windows CMD shell but not in a Windows git bash shell is that the classpath used to run the app contains one of the following:
relative paths (e.g. ../foo)
network drives (e.g. //servername/bah
See:
https://github.com/git-for-windows/git/issues/1028

How to launch a jar file on windows startup from the registry?

I am trying to launch a jar file on Windows Server 2008 R2 startup.
I tried to add a key\value to
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
I tried as a value several alternatives:
java -jar c:\jcm\jcm.jar
"java -jar c:\jcm\jcm.jar"
c:\program files(x86)\java\jre1.8.31\bin\java.exe -jar c:\jcm\jcm.jar
"c:\program files(x86)\java\jre1.8.31\bin\java.exe -jar c:\jcm\jcm.jar"
"c:\program files(x86)\java\jre1.8.31\bin\java.exe" -jar c:\jcm\jcm.jar
But none of them launched the program.
Can you advise please?
EDIT: Fixed exe to jar of course
You probably have a problem in the command line. I think it should be something like that last row that you have used but with jar and not exe.
"c:\program files(x86)\java\jre1.8.31\bin\java.exe" -jar c:\jcm\jcm.jar
You just need to test it in command line first and if it works it will work in the registry. You can also make a .bat file to start the java program and copy that to windows Startup Folder instead of using the registry.
The startup folder you can find here:
http://windows.microsoft.com/en-us/windows/run-program-automatically-windows-starts#1TC=windows-7
If it is Windows 10 then you may try this way-
Create a batch file e.g. (my-batch.bat with below statements.)
#echo off
title my-app batch script!
echo my-app welcomes you!
:: If your JAR contains GUI then use-
start javaw -Xmx200m -jar D:\Softwares\JAR\my-app-v1.0.jar
:: Otherwise use-
start java -jar D:\Softwares\JAR\my-app-v1.0.jar
Copy this my-batch.bat file at
C:\Users\pc\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
Restart your PC to execute your JAR on startup.
Now, You may check your running JAR using Command Prompt with below commands-
1. jps -l
Output will look like-
8120 sun.tools.jps.Jps
13276 D:\Softwares\JAR\my-app-v1.0.jar
2. tasklist /V

bash: jar: command not found

I'm using Jenkins to deploy the build.
We need to extract files from a .war into some directory.
We have an .xml file which includes commands to extract the files from the .war file and start the server.
The build is being created properly but the .war extraction is not happening and the destination folder is being left empty. The Jenkins Console shows the following output:
[sshexec] bash: jar: command not found
As read from other answers, I have set the PATH properly in .bashrc or in .profile but I'm still facing the same issue.
Install Java devel as follows:
yum install java-devel
To be specific, JAVA bin directory is not in your PATH variable. Add it to PATH variable. In order to search the executables, the OS need to have a list of directories to look up. So, Add the directory which contains 'jartool in thePATH` environment variable
Note : For Windows, Path separator is (;) and for Unix-like OS, Path separator is (:)
The "[sshexec]" tells me you are using some Jenkins plugin to execute a command on a remote host.
This usually means Jenkins executes this (or an equivalent thing by implementing the SSH protocol natively):
ssh user#remotehost 'jar arg1 arg2...'
What happens here is the sshd daemon on the remote host will execute the default shell of the user and ask the shell to execute the command line. The shell is typically not executed as a "login shell", meaning the shell will skip the initialization steps that login shells normally do when the user logs in interactively.
You can study man (name of your shell) to see exactly what the difference is between a shell executed with -l option and one executed without it. In the case of bash it essentially means .profile and .bashrc will not be executed, so any PATH modifications you might have there will not take place.
I think your best bet is to provide the full path to the jar command when you want to execute it.
As you are executing the command on remote host so, it will invoke the new Shell on the remote host. The PATH which you have set in the current host .bashrc file will not make any difference. Instead if you set the PATH for Java in remote host's .bashrc things should work else if you are running any script then mention the complete path for JAR like /usr/jdk64/jdk1.8.0_40/bin/jar -tf /tmp/jars/abc.jar while invoking the command on remote host.
Two ways to do:
export PATH=$PATH:/usr/jdk64/jdk1.8.0_40/bin ---> in remote host's .bashrc
/usr/jdk64/jdk1.8.0_40/bin/jar -tf /tmp/jars/abc.jar --> invoke the jar command with complete path for JAR from remote host.

Error launching sqoop client on windows

Per the installation directions I run:
./bin/sqoop.sh client
and it returns error:
could not find or load main class org.apache.sqoop.shell.SqoopShell
I'm setting up Sqoop for the first time. I have the server up and running on Redhat Linux. Now I am stuck running the client on Windows Server 2012. I am running hadoop v2 and sqoop-1.99.3-bin-hadoop200. At the command line I verified java is installed by running "java -version" at the command line and seeing "1.8.0". Scoop is written in Java 1.6. Does that matter? I'm having difficulty locating an active download link to 1.6 for windows for troubleshooting.
I tried installing Cygwin and running the command. Same error.
Locate the directory traversal for the case of client in sqoop.sh
# Build class path with full path to each library
for f in $SQOOP_CLIENT_LIB/*.jar; do
CLASSPATH="${CLASSPATH}:$f"
done
Just add the following search and replace params (note changes of colon to semicolon in classpath)
# Build class path with full path to each library
PARAMSEARCH="/c/"
PARAMREPLACE="C:\\"
for f in $SQOOP_CLIENT_LIB/*.jar; do
f=${f/$PARAMSEARCH/$PARAMREPLACE}
CLASSPATH="${CLASSPATH};$f"
done
I had the same issue running on Windows 8.1. Turns out it's caused because sqoop.sh uses POSIX style directory paths. So / instead of . This results in the script being unable to set the correct CLASSPATH. This could have been remedied by using a cmd file for Windows. I don't know why they didn't do it. There are cmd files for catalina and such but not for launching sqoop!
Anyway I got around this issue by adding all the jar files in the shell\lib folder to CLASSPATH. You do have to add each & every jar file there and not just the folder path. A restart was required after this which was annoying. However the shell script will still not launch the client even after this change. The little trick I used is to just launch the client at the command prompt from the shell\lib folder with the following command
***java org.apache.sqoop.shell.SqoopShell***
Now I get the groovy prompt from where I can run all the commands provided here
I used the following steps to configure sqoop in a windows machine and now able to work with sqoop 1.99.3 successfully.
*Cygwin must be installed before continuing further steps. Also its just for using the native libraries, we can interact with sqoop directly from windows command prompt.
Save the sqoop package folder in “C:” drive name as sqoop
Copy the hadoop lib folder “hadoop” from C:\hadoop\share into C:\usr\lib\hadoop [If this directory doesn't exists, then create one]
Change the hadoop configuration properties in the file “sqoop.properties” from the location “C:\sqoop\server\conf” as below
at line:132
org.apache.sqoop.submission.engine.mapreduce.configuration.directory=C:\hadoop\etc\hadoop
Copy the sqoop.properties and sqoop_bootstrap.properties from “C:\sqoop\server\conf” into “C:\sqoop\server\bin”.
Set the environment variables for sqoop home as well as path:
SQOOP_HOME = C:\sqoop
Starting the server:
Open Command prompt (run as Administrator) and enter into the $SQOOP_HOME location and type command as follows
C:\sqoop> cd server\bin
C:\sqoop\server\bin> catalina start
The catalina server will be start and check it in the below location
http://localhost:12000/sqoop
Client Shell Command
Open the command prompt and enter the following command
java -classpath C:\sqoop\shell\lib\sqoop-shell-2.0.0-SNAPSHOT.jar;C:\sqoop\shell\lib\sqoop-common-2.0.0-SNAPSHOT.jar;C:\sqoop\shell\lib\sqoop-client-2.0.0-SNAPSHOT.jar;C:\sqoop\shell\lib\log4j-1.2.16.jar;C:\sqoop\shell\lib\json-simple-1.1.jar;C:\sqoop\shell\lib\jline-0.9.94.jar;C:\sqoop\shell\lib\jersey-core-1.11.jar;C:\sqoop\shell\lib\jersey-client-1.11.jar;C:\sqoop\shell\lib\jansi-1.7.jar;C:\sqoop\shell\lib\hamcrest-core-1.3.jar;C:\sqoop\shell\lib\groovy-all-1.8.5.jar;C:\sqoop\shell\lib\commons-lang-2.6.jar;C:\sqoop\shell\lib\commons-cli-1.2.jar org.apache.sqoop.shell.SqoopShell
The client shell command will be displayed as :
Sqoop Shell: Type 'help' or '\h' for help.
sqoop:000>
Hope this helps
Thanks

Categories