Hi, i have a java program, it will fetch the data from oracle data base and it will be the output. so now what i need is ? using shell script i need to get the output from that java code will it pos/

Hi, i have a java program, it will fetch the data from oracle data base and it will be the output. so now what i need is ? using shell script i need to get the output from that java code will it pos/
Midhun KAsked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
What's the difficulty? All you need to do (from what you said) is execute the java app in the script
0
 
awking00Commented:
Can you post your java code?
0
 
Murugesan NagarajanSubject-matter expert at C++ C delivery, implementation, at UNIX oriented operating systems (Windows: CYGWIN_NT MINGW32_NT MINGW64_NT)Commented:
>> will it pos/
It is possible
1. install cygwin (64 bit installation) http://www.cygwin.com/setup-x86_64.exe
or install (32 bit installation) http://www.cygwin.com/setup-x86.exe
or mingw
2. Open CYGWINDIRECTORY\bin\bash.exe
3. BETTER_USE_FULL_PATH_java SampleError >delete.txt 2>delete.txt
$ /bin/cat delete.txt
Error: Could not find or load main class SampleError

Open in new window

However that is not possible inside command prompt:
java SampleError >delete.txt 2>delete.txt
The process cannot access the file because it is being used by another process.

Open in new window



Inside command prompt use two different output/error files:
C:> full_path_java SampleError >output.txt 2>error.txt
C:\> TYPE output.txt
C:\> TYPE error.txt
Error: Could not find or load main class SampleError

Open in new window

0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
CEHJCommented:
First of all, why are you using Cygwin for javac/java? It will run fine under Windows
0
 
Murugesan NagarajanSubject-matter expert at C++ C delivery, implementation, at UNIX oriented operating systems (Windows: CYGWIN_NT MINGW32_NT MINGW64_NT)Commented:
Written cygwin for:
1. writing automation shell script for any application at all platforms (cygwin at Windows).
0
 
CEHJCommented:
OK. If bash is to be found everywhere then i would suggest you
a. set JAVA_HOME as variable (installation directory of JDK)
b. set PATH with beginning as
export PATH="SJAVA_HOME/bin:$PATH"

Open in new window


Do that in ~/.bashrc
0
 
Murugesan NagarajanSubject-matter expert at C++ C delivery, implementation, at UNIX oriented operating systems (Windows: CYGWIN_NT MINGW32_NT MINGW64_NT)Commented:
@Midhun
You can handle following exceptions using ~/.bashrc or ~/.kshrc or ~/.profile or ...
Example:
#Following example using /usr/java/jdk1.7 for JAVA_HOME
if [[ "" == "$JAVA_HOME" ]]
then
	if [[ -d "/usr/java/jdk1.7" ]]
	then
		if [[ -d "/usr/java/jdk1.7/bin" ]]
		then
			export JAVA_HOME=/usr/java/jdk1.7
		else
			echo "/usr/java/jdk1.7/bin No such directory"
			echo "Hence not setting JAVA_HOME environment variable"
		fi
	else
		echo "/usr/java/jdk1.7 No such directory"
		echo "Hence not setting JAVA_HOME environment variable"
	fi
fi
if [[ "" != "$JAVA_HOME" ]] && [[ ! -d "$JAVA_HOME" ]]
then
	echo "$JAVA_HOME No such directory"
	echo "Hence unsetting $JAVA_HOME"
	unset JAVA_HOME
elif [[ ! -f "$JAVA_HOME/bin/javac" ]]
then
	echo "$JAVA_HOME/bin/javac No such file"
elif [[ ! -x "$JAVA_HOME/bin/javac" ]]
then
	echo "$JAVA_HOME/bin/javac execute permission denied"
	/bin/ls -ld "$JAVA_HOME/bin/javac"
else
	SEARCH_JAVA_HOME_IN_PATH=''`echo "$JAVA_HOME" | /bin/sed "s/\//\\\\\\\\\//g;"`''
	echo $PATH | /bin/egrep  "^$SEARCH_JAVA_HOME_IN_PATH" >/dev/null 2>&1
	JAVA_HOME_NOT_PRESENT_IN_PATH=$?
	if [[ 0 -ne $JAVA_HOME_NOT_PRESENT_IN_PATH ]]
	then
		export PATH="$JAVA_HOME/bin:$PATH"
		unset SEARCH_JAVA_HOME_IN_PATH
	fi
fi

Open in new window

Above code was tested including all exceptions and all types of re login.
0
 
CEHJCommented:
:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.