Calling Java Method from UNIX using shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Calling Java Method from UNIX using shell script
# 1  
Old 01-06-2010
Calling Java Method from UNIX using shell script

Hi All,

I need to call a java method from a shell script. I know we can use the command
java ClassName
to call the main method in it. But I need to call another method that is there in the class and pass an email to it.

Can I use
java ClassName.MethodName(email)

Any help will be useful.

Thanks.
# 2  
Old 01-06-2010
Yes..provided the CLASSPATH is properly set.
But passing the email body to a method depends how you written the method.
# 3  
Old 01-06-2010
Thanks Dennis. But can you give me an example of how to call a method inside a java class and pass, say a number argument, from command line
Class name: testClass
Method inside testClass to be called: testMethod()
argument: testNumber

java testClass.testMethod(testNumber) ??

Thanks.
# 4  
Old 01-06-2010
Try something like:

test.sh
Code:
 
export JAVA_HOME=<java home dir>
export CLASSPATH= <classpath>
NUMBER=$1;
$JAVA_HOME/bin/java testClass.testMethod($NUMBER)

sh test.sh 1232
# 5  
Old 01-06-2010
This does not work. The compiler tries to find a class called testMethod inside testClass.
I get a NoClassDefFoundError for this.

Does anybody have a solution for this issue?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Control not returning from Sqlplus to calling UNIX shell script.

Hello All, I have exactly same issue @vikas_trl had in following link: https://www.unix.com/shell-programming-and-scripting/259854-control-not-returning-sqlplus-calling-unix-shell-script.html I wonder if he or somebody else could find the issue's cause or the solution. Any help would... (4 Replies)
Discussion started by: RicardoQ
4 Replies

2. Shell Programming and Scripting

Control not returning from Sqlplus to calling UNIX shell script.

Hello All, I have a UNIX script which will prepare anonymous oracle pl/sql block in a temporary file in run time and passes this file to sqlplus as given below. cat > $v_Input_File 2>>$v_Log << EOF BEGIN EXECUTE IMMEDIATE 'ALTER SESSION FORCE PARALLEL DML PARALLEL 16'; EXECUTE... (1 Reply)
Discussion started by: vikas_trl
1 Replies

3. Shell Programming and Scripting

How to pass the environment name while calling java program from unix script?

Hi, I'm trying to test one unix shell script in dev environment. But I'm not sure how to pass the environment in my java program calling code. I'm trying to use -DconsumerEnv="DEV" but unfortunately I get 'null' while trying to print the value from java class. System.out.println("Environment: "+... (4 Replies)
Discussion started by: Pramit
4 Replies

4. UNIX for Dummies Questions & Answers

calling a unix shell script from sqlplus

I want to execute a shell script from sqlplus prompt and get its output back to sqlplus. Is this possible? if yes just give me an example for doing that. (2 Replies)
Discussion started by: boopathyvasagam
2 Replies

5. Shell Programming and Scripting

Calling a request set from Unix shell Script

Hi All, I want to call a concurrent request set from a shell script. I am getting the syntax error "syntax error at line 417 : `(' unexpected" in the below script. v_request_id=fnd_request.submit_request(application => 'APPL_SHORT_NAME' ,program => 'PROGRAM_SHORT_NAME' ... (4 Replies)
Discussion started by: swatipevekar
4 Replies

6. Shell Programming and Scripting

Unix Shell script vs Java

Members, I been faced with an issue where i have to sale my project against JAVA.would like to know more on the strong point of shell script (bash shell) over java.I have a very limited knowledge on java.is there anyone who has worked on java and shell scripting in both and really been able to... (13 Replies)
Discussion started by: navojit dutta
13 Replies

7. Shell Programming and Scripting

Calling an Oracle Stored Procedure from Unix shell script

hai, can anybody say how to call or to execute an oracle stored procedure in oracle from unix... thanks in advance.... for ur reply.... by, leo (2 Replies)
Discussion started by: Leojhose
2 Replies

8. UNIX for Advanced & Expert Users

Unix Machine for calling Native Method of C

hi all i have a unix machine (FBD). I have Also installed java of Version (j2sdk1.4.1_07) on unix machine. Now i want to Call C Native function in Java Which is declared as Native. i am doing this by following steps: 1) Making Echo.java File Which is having The following lines of code.... (5 Replies)
Discussion started by: sbeyonduf007
5 Replies

9. Shell Programming and Scripting

Help with shell script - Unix Gurus calling

Unix Gurus, I have been breaking my head to get this done..seems simple.. I need to read a flat file and based on a key word in a line, i need to skip the previous 3 lines. eg : Line1 Line2 Line3 Line4 Line5 Line6 Error Line7 Line8 Line9 Error Line10 (4 Replies)
Discussion started by: ravred
4 Replies

10. UNIX for Dummies Questions & Answers

Java program calling a UNIX command

I was wondering if it was possible to call a unix command directly from a Java program during run-time. This command could very very basic e.g. "ps -ef" returned as a string, all I need is a starting place so if anyone has any suggestion or examples I would be very grateful (2 Replies)
Discussion started by: QUartz Ite
2 Replies
Login or Register to Ask a Question