aspose file tools*
The moose likes Beginning Java and the fly likes Can you guys please explain me this Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can you guys please explain me this " Watch "Can you guys please explain me this " New topic
Author

Can you guys please explain me this

Richards Milan
Greenhorn

Joined: Jun 24, 2012
Posts: 29

In the "main" method ' public static void main(String[] args) ', why are we passing the String parameter args ?


Do you know why Java programmers wear specs ? Its because they don't 'C#'
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1824
    
    7

Here you go

The main method accepts a single argument: an array of elements of type String.

public static void main(String[] args)

This array is the mechanism through which the runtime system passes information to your application. For example:

java MyApp arg1 arg2

Each string in the array is called a command-line argument.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Richards Milan
Greenhorn

Joined: Jun 24, 2012
Posts: 29

thank you Jelle ! it was really helpful
Richards Milan
Greenhorn

Joined: Jun 24, 2012
Posts: 29

what exactly does " setting a classpath " mean ? why is it nescessary to set environment variables PATH , CLASSPATH in windows platform ??
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14350
    
  22

"Setting a classpath" simply means setting the CLASSPATH environment variable.

Windows uses the PATH environment variable to find programs to execute. The PATH consists of a list of directories where Windows will look for *.exe files (executable programs). Normally, you'll want to add the bin directory of your JDK installation directory to the PATH, so that Windows can find the JDK tools when you're working in a command prompt window. See Updating the PATH Environment Variable in the JDK installation instructions.

The CLASSPATH is used by Java to find Java *.class files. Normally you'll want to leave the CLASSPATH environment variable not set.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11480
    
  16

FWIW - these are not unique to Windows. Unix/Linux uses the same environment variables. I don't know enough about the Mac OS, but i would be surprised if there wasn't something similar there.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39865
    
  28
Richards Milan,
Your post was moved to a new topic.
 
Don't get me started about those stupid light bulbs.
 
subject: Can you guys please explain me this