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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
What's the difficulty? All you need to do (from what you said) is execute the java app in the script
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
awking00Information Technology SpecialistCommented:
Can you post your java code?
0
murugesandinsShell_script Automation /bin/bash /bin/bash.exe /bin/ksh /bin/mksh.exe AIX C C++ CYGWIN_NT HP-UX Linux MINGW32 MINGW64 SunOS Windows_NTCommented:
>> 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
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

CEHJCommented:
First of all, why are you using Cygwin for javac/java? It will run fine under Windows
0
murugesandinsShell_script Automation /bin/bash /bin/bash.exe /bin/ksh /bin/mksh.exe AIX C C++ CYGWIN_NT HP-UX Linux MINGW32 MINGW64 SunOS Windows_NTCommented:
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
murugesandinsShell_script Automation /bin/bash /bin/bash.exe /bin/ksh /bin/mksh.exe AIX C C++ CYGWIN_NT HP-UX Linux MINGW32 MINGW64 SunOS Windows_NTCommented:
@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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.