Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Problem Description: How to compile a java file? Solution: Following example demonstrates how to compile a java file using javac command. c:\jdk\demoapp> javac First.java Result: The above code sample will produce the following result. First.java compile successfully. Problem Description: How to set multiple classpath? Solution: Following example demonstrates how to set multiple classpath. Multiple class paths are separated by a semicolon. c:> java -classpath C:\java\MyClasse1;C:\java\MyClass2 utility.testapp.main Result: The above code sample will produce the following result. Class path set. Problem Description: How to set destination of the class file? Solution: Following example demonstrates how to debug a java file using =g option with javac command. c:> javac demo.java -g Result: The above code sample will produce the following result. Demo.java will debug. Problem Description: How to set classpath? Solution: Following example demonstrates how to set classpath. C:> java -classpath C:\java\DemoClasses utility.demoapp.main Result: The above code sample will produce the following result. Class path set. Problem Description: How to view current classpath? Solution: Following example demonstrates how to view current classpath using echo command. C:> echo %CLASSPATH% Result: The above code sample will produce the following result. .;C:\Program Files\Java\jre1.6.0_03\lib\ext\QTJava.zip Problem Description: How to set destination of the class file? Solution: Following example demonstrates how to set destination of the class file that will be created after compiling a java file using -d option with javac command. c:> javac demo.java -d c:\myclasses Result: The above code sample will produce the following result. Demo application executed. Problem Description: How to run a class file? Solution: Following example demonstrates how to run a class file from command prompt using java command. c:\jdk\demoapp>java First Result: The above code sample will produce the following result. Demo application executed. Problem Description: How to check version of java running on your system? Solution: Following example demonstrates how to check version of java installed on your system using version argument with java command. java -version Result: The above code sample will produce the following result. java version "1.6.0_13" Java(TM) SE Runtime Environment (build 1.6.0_13-b03) Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing) Problem Description: How to set classpath when class files are in .jar file? Solution: Following example demonstrates how to set class path when classes are stored in a .jar or .zip file. c:> java -classpath C:\java\myclasses.jar utility.testapp.main Result: The above code sample will produce the following result. Class path set.