Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference between exe file and batch file

 
samdeep aarzoo
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone tell me please
what is the diffrence between *.exe file and *.bat( msdos batch file)
 
Marilyn de Queiroz
Sheriff
Posts: 9065
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
an exe file is compiled code -- unreadable by humans.
 
samdeep aarzoo
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and about *.bat
 
Norm Radder
Ranch Hand
Posts: 1015
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Rick O'Shay
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1015
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
samdeep aarzoo
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15359
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 661
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
samdeep aarzoo
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 9065
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[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
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic