Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
This page was exported from TechnicalStack [ http://technicalstack.com ]
Export date: Sat Apr 29 17:55:55 2017 / +0000 GMT
Setting classpath and Running Java Programme
Setting up the path for Windows
Assuming we have installed java in C:programeFilesjavajdkdirectory
->Right click on “My computer” and select “Properties:
-> Click on the “Environmental variable” button under the “Advance” tab then enter the “Path” variable to
C:programeFilesjavajdkbin;
Setting up the path form Command Prompt:‘SETPATH'=/PATH/;C:programeFilesjavajdkbin;
After this we have to set the class variable upto lib directory.
Difference between Path and ClassPath
ClassPath:- describes the Location where dot class(.class) files are available.
Path:- describes the Location where binary executable Path is available.
For eg:When we run Javac command Javac.exe gets executed and will create Java.class file Javac Test.java
=> Java.class file
Ways to run a Java programme:We can run a java programme in the followings ways:1. With Java command to run .classfile
Java JarDemo press enter
2. Java command to run . jar file
Java-jarDemo.jar
3. By double clicking a jar file
4. By double clicking on batch file
Batch File:- Batch file is a group of command which is saved as filename.bat
Making a Batch File:Open a text file and type:- java-cpC:democlass jar Demo and this file as XYZ.bat
How to cterate executable jar file
Jar is a group of executable .class file.
For eg.
Import java.awt.*;
Import java.awt.event*;
Public Class JarDemo
{
Public Static Void main(String[] args)
{
Frame f=new Frame();
f.addWindowListener(new WindowAdapter{
Public Void WindowClosing(WindowEvent)
{
For(int i=1;i<10;i++)
System.Out.Println(“I AM CLOSING
WINDOWS”+I);
System.exit(0);
}
});
f.add(newLabel(“I CAN CREATE EXECUTABLE JAR FILES ‘,' “));
f.setSize(500,500);
f.setVisible(true);
}
}
Complile the code by using the command:Javac JarDemo.java
It will create two types of .class file JarDemo.class and JarDemo$1.class
We can also create Manifest File which provides information about the jar file.
Command:- jar-cvfm demos.jar
Command to Run jar file:- Java-jar demos.jar
Difference between JDK,JRE,AND J VM
JDK(Java Development Kit):- JDK provides environment to develop and run the java program m e.
JRE(Jav a Runtime Environment):- It provides environment to run the java programme.
JVM(Java Virtual Machine):- JVM is an interpreter to run java programme line by line.
JDK=JRE+development tools
JRE=JVM+Library classes
Post date: 2016-02-20 04:22:25
Post date GMT: 2016-02-20 04:22:25
Post modified date: 2016-08-28 15:28:45
Post modified date GMT: 2016-08-28 15:28:45
Powered by [ Universal Post Manager ] plugin. MS Word saving format developed by gVectors Team www.gVectors.com