This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes difference between  exe file and batch file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "difference between  exe file and batch file" Watch "difference between  exe file and batch file" New topic
Author

difference between exe file and batch file

samdeep aarzoo
Ranch Hand

Joined: Jun 09, 2005
Posts: 160
can anyone tell me please
what is the diffrence between *.exe file and *.bat( msdos batch file)
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9048
    
  10
an exe file is compiled code -- unreadable by humans.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
samdeep aarzoo
Ranch Hand

Joined: Jun 09, 2005
Posts: 160
and about *.bat
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 687
    
    1
A batch file is read and interpreted by a batch file interpreter which has its own language that you write the batch file in.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Batch files are handy for SIMPLE setup before running programs. I just answered another post with a few lines that are typical for me:

If a batch file exceeds a few lines or needs to use variables or anything complex, I jump right to Windows Scripting Host. WSH is optional on your XP install but lets you write helpful scripts in JavaScript or VBScript.

Actually if it's just for me, I go to REXX next, but that's cause I'm an old mainframe curmudgeon. Others will tell you they go to Perl or Python or one of the bazillions of scripting languages out there.
[ August 21, 2005: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Rick O'Shay
Ranch Hand

Joined: Sep 19, 2004
Posts: 531
Sandeep, there are two general types of programs: interpreted and compiled. Compiled programs contain machine code that can be executed directly by the CPU. Scripts must be interpeted by a compiled program specially designed for that task.

Compiled programs do not contain alpha-numeric characters, they contain a binary representation of the CPU instructions that make up the program. In the case of script files, they are usually text that can be viewed with any text editor.

In the case of a .bat file, command.com is the intepreter and it's an integral part of Windows. Using .exe for compiled programs and .bat for command scripts is a convention. There are variations: .com for binary executables, .cmd for scripts.
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 687
    
    1
Stan,
Where can I get REXX for a Windows system? What version windows is required?
I was an IBM mainframe programmer for years and loved REXX.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Originally posted by Norm Radder:
Stan,
Where can I get REXX for a Windows system? What version windows is required?
I was an IBM mainframe programmer for years and loved REXX.


Wave your google wand chanting "REXX windows" and enjoy.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
samdeep aarzoo
Ranch Hand

Joined: Jun 09, 2005
Posts: 160
so for any jdk application we can make exe
but not .bat file
and in tomcat web application we can have .bat file also
because it use scripting language
please correct me i an wrong in understanding
Rick O'Shay
Ranch Hand

Joined: Sep 19, 2004
Posts: 531
Neither assumption is correct and it has little to do with tomcat per se. Typical Java applications are not exe files, nor are they text scripts. An application in Java is composed of machine code, like an exe, however it's designed for a virtual machine implemented in software. Chips that execute Java programs directly do exist, but most Java runs on Intel, AMD, Sparc or other common CPUs. To accomplish that, the virtual Java machine code, called byte code, has to be translated to a form that the real CPU can execute.

Java Source -> Byte Code -> Machine Code

There is plenty of information out there on all of these topics. I suggest snorkeling around the web for a while.
samdeep aarzoo
Ranch Hand

Joined: Jun 09, 2005
Posts: 160
can anyone help me
what is the differnce between scripting langusge(xml)
and compiler based lang (jdk)

AS we all know we choose language according to our problem
so which type of problem can be easily sorted out by scripting
lang rather than compiled lang.

and how they work together
pleaase help
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14278
    
  21

Languages like JavaScript, Perl and PHP are scripting languages. Most scripting languages are quite easy to learn and don't have very strict type checking. Scripting languages are often useful for small tasks, for which you want to write a small piece of code quickly. Because the code is interpreted, not compiled, it doesn't run as fast as compiled code.

Compiler-based languages like Java, C++ and C are more useful for writing larger, more complex programs. Most of those languages have strict type checking to help programmers write more robust code. Before you can run it, you have to compile the source code to machine instructions; JVM instructions for Java, native machine code for C and C++.

XML is not a scripting language. XML is not even a programming language. XML is a language used to represent data in logical structure.
[ August 24, 2005: Message edited by: Jesper de Jong ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Re REXX: I use Regina supported by Mark Hessling and on SourceForge. I used to use Personal Rexx which is not free but is a very thorough implementation by one of the leaders in the language.

The compiled / interpreted distinction is good, though sometimes fuzzy. There are many ways to get things run ... here are a few:

source -> compiler -> objectcode -> linker -> exe

source -> compiler -> bytecode -> interpreter

source -> interpreter

Some interpreters like mainframe REXX do a "pre-execute" to something like bytecode on the fly, and sometimes let you save that optimized format to disk. Some Java VMs do partial or complete compile to machine language. Some compiled programs can interpret scripts in the same or other languages. Smalltalk uses other unique terms like "image". Many of these things are pretty hard to categorize cleanly, aren't they!
samdeep aarzoo
Ranch Hand

Joined: Jun 09, 2005
Posts: 160
hi everyone
please help me in understanding this concept

*.java --> *.class--->*.obj(memory allocation)

can i see how much memory allocated to my source program
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Javac.exe, the compiler, reads .java and writes .class files. Java.exe, the JVM, loads class files into memory. If you reference just the class or only static variables and static methods things stop at loading the class. If you create an instance then the JVM allocates memory and creates a set of the instance variables defined in the class.

Java doesn't give you an easy or reliable way to measure the memory use of loading a class or creating an instance. You can serialize an instance and see how big that is. It's larger than the object itself because of some metadata.

Class.forName("SomeClass"); <- Loads the class but no instances

SomeClass x = new SomeClass(); <- Loads the class and allocates an instance

Did that help?
samdeep aarzoo
Ranch Hand

Joined: Jun 09, 2005
Posts: 160
so according to u there is no way to find
how much memory is allocated to any object .

in language c there is one concept that is "dynamic memory management"
that means we can allocate memory dynamiclly .
and it has also "sizeof "operator to tell size of memory used by particular program.

but in java is there any way to allocate dynamic memory .
i think in java e verything is done by " garbage collector" its a thread
running insight . which allocate and delocate memory.
so let comes to my main question
suppose i made a class
than i made a object of it
so memory is allocated
so can i find how much memory is allocated through program
but we are using others object also by importing their package
i m not clear in my concepts just saying what i think
Rick O'Shay
Ranch Hand

Joined: Sep 19, 2004
Posts: 531
There is no sizeof operator in Java but sizeof does not to a deep analysis of classes in C++ either: pointer is one machine word, not the sizeof the object it points to. It's used in C++ for portable memory allocation but it would serve no purpose in a Java application. Where it would be useful is in simplifying and improving memory profiling. In that case sizeof matters.
samdeep aarzoo
Ranch Hand

Joined: Jun 09, 2005
Posts: 160
Java doesn't give you an easy or reliable way to measure the memory use of loading a class or creating an instance. You can serialize an instance and see how big that is. It's larger than the object itself because of some metadata.


how can we serialize the instance ???
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Look at ObjectOutputStream. Hook it up to a byte array output stream and see what gets written. I think it's quite a bit bigger than the real memory footprint for an object because it encodes binary data. Anybody know the algorithms well enough to say what to expect?
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

If Your program is really big and you need to find the memory allocations, i suggest you to Use tools like JProbe. They might tell you the allocation of memory.


If you are not laughing at yourself, then you just didn't get the joke.
samdeep aarzoo
Ranch Hand

Joined: Jun 09, 2005
Posts: 160

Class.forName("SomeClass"); <- Loads the class but no instances

SomeClass x = new SomeClass(); <- Loads the class and allocates an instance




these statements are really very good clear some sort of picture
phil shea
Greenhorn

Joined: Aug 24, 2005
Posts: 12
Someone said, in Java memory is allocated by Garbage collector. Is that true? I thought memory in java is allocated by JVM.

-phil
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
The Garbage Collector is one of many little animals roaming around the JVM. It finds unreachable objects and returns them to available memory - it DEallocates. I've never worried about the name of the part of the JVM that allocates memory. You might try recursion until you run out of memory and see if the stack trace has its name ... along with a couple million copies of the name of your method
samdeep aarzoo
Ranch Hand

Joined: Jun 09, 2005
Posts: 160
hi
our discussion is moving toward memory management.
lets talk about memory management. how memory is allocated.
firstly by memory we mean "Ram" .
what i know
memory is divided into parts in this way
for storing at the time of execution :
our code: for our static code
for storing function variable : stack short term memory
for storing objects : heaps : long term memory

where goes static variable???
samdeep aarzoo
Ranch Hand

Joined: Jun 09, 2005
Posts: 160


a.java(compile)---> a.class ------>java virtual machine(loader , linker, verifier , bytecode interpreter)----->a.class(load)---->verify----
------>link( another b.class link to a.class )--------->byte code interpreter.

how byte code interpreter works


please tell
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9048
    
  10
[b]our discussion is moving toward memory management.{/b}

What if you post a new thread regarding this subject in Java in General(intermediate) since this is not a beginners subject.
samdeep aarzoo
Ranch Hand

Joined: Jun 09, 2005
Posts: 160
hi Marilyn de Queiroz
this thread should be in begineer only;
i m not an expert in java . i dont know much about java.
i m learning.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Try these Under the Hood of the JVM articles. I'm betting they'll answer lots of questions and raise lots more, but if you're really interested in this stuff they'll be a lot of fun.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: difference between exe file and batch file