wood burning stoves 2.0*
The moose likes Java in General and the fly likes how to write a script in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to write a script in java" Watch "how to write a script in java" New topic
Author

how to write a script in java

shaharyar khan
Greenhorn

Joined: Aug 16, 2011
Posts: 9
hi dudes
please anyone tell me that how to write a script in java. with any good , understanable and coded example...
thanks in advance to my great helpers
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7781
    
  21

shaharyar khan wrote:please anyone tell me that how to write a script in java. with any good , understanable and coded example...

If you mean a dynamic late-binding script that doesn't need compiling: not possible. You should probably look at JavaScript.

It is possible to write a Java program that can read some scripts and execute their code using the javax.ScriptEngine interface, but a working example for anything more than "Hello world" would take a lot of space. I suggest you read the tutorial.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
shaharyar khan
Greenhorn

Joined: Aug 16, 2011
Posts: 9
thanks winston.let me clear you something that some one given me a task. which is not clear to me.
1.please tell me why we use script?
and also tell me please what is the difference late binding script (as you told) and other script.
2. the assignment is to read a file and write it in another (.owl extension file) through script
if possible please give me your personal email adress as i want to communicate with you directly on mail.
thanks
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
shaharyar khan wrote:
2. the assignment is to read a file and write it in another (.owl extension file) through script
if possible please give me your personal email adress as i want to communicate with you directly on mail.
thanks

Is that a assignment you want to accomplish using script... else it's just a file copy which is easier to code...
And please UseTheForumNotEmail... I would learn something reading the posts
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7781
    
  21

shaharyar khan wrote:1.please tell me why we use script?
and also tell me please what is the difference late binding script (as you told) and other script.

None. Most scripting languages are late-binding because they are usually interpreted, not compiled. This allows them to evaluate things such as strings, variables and files containiing scripting commands at runtime, rather than going through a static binding process such as a compiler or a linker.

2. the assignment is to read a file and write it in another (.owl extension file) through script

If, as John says, this a merely a file copying exercise, then you probably don't need a scripting interface. If any sort of syntax checking is required, you might; but I've never done it myself, so I don't know if Java provides an OWL interpreter through its scripting interface. There may be 3rd party libraries around that do.

if possible please give me your personal email adress as i want to communicate with you directly on mail.

I'm afraid that goes against forum rules; but if you want to provide some extra detail, I'm sure someone will have an idea that might help.

Winston
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4388
    
    8

Maybe were focussing too much on the word "script" here? - I'm not certain it's been used in its technical sense.

So, Shaharyar, can you give us more information about what it is you're trying to do? What you've told us so far is nowhere near enough for someone to help you with it.
shaharyar khan
Greenhorn

Joined: Aug 16, 2011
Posts: 9
thanks everyone for considering me. let me ask you the things one by one.
1. please tell me the purpose of writing a automated script ? and what is the link of programming language with the script
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7781
    
  21

shaharyar khan wrote:thanks everyone for considering me. let me ask you the things one by one.
1. please tell me the purpose of writing a automated script ? and what is the link of programming language with the script

Not sure what you mean by an "automated script". Do you mean one that's run on a scheduler?

The purpose writing a script is the same as it is for any piece of code: you want to automate it (whatever 'it' is).

As for the link between scripts and languages: As I said above, "programming languages" are usually statically compiled and/or linked, scripts are interpreted; but the distinction is getting more blurred these days. Lots of scripts call themselves "scripting languages".

But I think Matthew's right; rather than just firing a bunch of questions, why don't you just explain what it is you want to do?

Winston
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 692

shaharyar khan wrote:hi dudes
please anyone tell me that how to write a script in java. with any good , understanable and coded example...
thanks in advance to my great helpers

which scripts shell scripts or some other scripts ?
if it is a shell scripts for linux & unix platform then ,
i suggest an alternative make a file and write all the commands you want your script to perform and save it with extension .sh and give it a full rwx permission using java
then using Desktop class try to open that file , in that way you could run your script in unix or linux platforms


The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
shaharyar khan
Greenhorn

Joined: Aug 16, 2011
Posts: 9
thnaks naved momin
your explaination clears me about script and thanks 2 all
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to write a script in java