How to call Java classes/methods from ksh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to call Java classes/methods from ksh
# 1  
Old 06-23-2006
How to call Java classes/methods from ksh

Hi all, i am new to shell scripts and have one doubt.

Can we call ava classes/methods from shell scripts? if yes how?
# 2  
Old 06-23-2006
Yes you can call java classes.

Code:
#! /bin/ksh

export CLASSPATH=/dir/containing/the/class:$CLASSPATH

/path/to/java HelloWorld

# 3  
Old 06-23-2006
Vino,

Thanks for your reply but can u explain the CLASSPATH part of it??

Thanks,
Girish
# 4  
Old 06-23-2006
Also, how to call the methods of the class??
# 5  
Old 06-23-2006
Quote:
Originally Posted by girish.sh
Vino,

Thanks for your reply but can u explain the CLASSPATH part of it??

Thanks,
Girish
Lets say your classfile HelloWorld is in the directory ~/java/samples/class. Then you need to either
- add that path to the classpath setting
- or add a . to the classpath.
# 6  
Old 06-23-2006
Quote:
Originally Posted by girish.sh
Also, how to call the methods of the class??
Calling methods is the class's responsibility. It depends on how you have coded your class.
# 7  
Old 06-23-2006
Yes but from shell script, we call class like path/to/java classname

so if i want to call method classMethod, call will be like this?

"path/to/java classname.classMethod()"
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Java Abstract Classes

Can anyone tell me if this is correct when creating classes in Java? public abstract class Animal { public class Point { public int x,y; } public class Animal { protected Point loc; protected String name; protected Random rng; String... (3 Replies)
Discussion started by: totoro125
3 Replies

2. Programming

Set java classes path

I add some new java jar files in the old project, how can I edit the class path? How can I compile all the java classes by just type 'C':o (3 Replies)
Discussion started by: Hscript
3 Replies

3. Shell Programming and Scripting

Script for adding few methods to bunch of Java files

Hi I have around 1000+ java file under different folder in /home/raxit/source and in each file i want to add a fix method. -------- /* Some comment for few lines like header block etc.. */ package import class A { method1 () { } method2 () (3 Replies)
Discussion started by: raxitsheth
3 Replies

4. Shell Programming and Scripting

Call java program from shell and pass values

Hi All, Can anybody please help me with how can i call my java program from shell and also pass parameter along with it so that the program can interpret the value/int and update the database. Thanks in advance Neha (1 Reply)
Discussion started by: Neha Goyal
1 Replies

5. Programming

Java can call C under Unix?

Under windows environment,I can compile C code into dll,then I can use Java to call this dll. I want to know whether Java can call C under Unix environment? How to do it? Where can I get example Java and C code? Thanks (1 Reply)
Discussion started by: konvalo
1 Replies

6. Shell Programming and Scripting

how to call java prog from shell script

I have a java program to validate a XML file. I want to call this java program in a shell script which will be registered as concurrent program in oracle apps. Can anyone please let me know the step by step appraoch required to call java program in shell script like ....intial steps... (1 Reply)
Discussion started by: kcp_pavan
1 Replies

7. Shell Programming and Scripting

call constructor of java class in script

Hi, Is it possible to call the constructur of a java class in a shell script? I know you can call static methods, but can you also call the constructor? tnx. (1 Reply)
Discussion started by: thebladerunner
1 Replies

8. Programming

how can compile cpp code containing references to java classes

hi there is example (on link given below )of such code that contains java class reference in c++ program. http://slackware.cs.utah.edu/pub/slackware/slackware-7.1/docs/Linux-HOWTO/Process-Monitor-HOWTO I am new in linux environment. and not able to compile it. when i compile it through... (1 Reply)
Discussion started by: surinder
1 Replies

9. Shell Programming and Scripting

Shell script to call multiple java commands

Hi, I want to call multiple java commands through a .sh file. I have drafted one with my least knowledge. But its not working. Pls help. I am trying to run this from Sun Solaris (OS 5.10) server with 10g oracle database. echo \* starting script AUTORUN echo \* get the Monitor path... (4 Replies)
Discussion started by: vivekdn
4 Replies

10. Shell Programming and Scripting

How to call Java by using shell script

Hi All, I am new to shell script, just wanted you guy to help. How do i call a java program by using shell script, pls give some samle code for it, thank you ver much. (2 Replies)
Discussion started by: aaabbb123123
2 Replies
Login or Register to Ask a Question