answersLogoWhite

0

Basic commands use in java

User Avatar

Anonymous

13y ago
Updated: 8/17/2019
Getting StartedJava is in /usr/local/java; make sure that this directory is in your load path. Use javac to compile java programs as in prompt% javac Hello.java

The compiler produces files with the extension .class, which is the object code for each of the classes defined within the file.

If you've written an application, you can run it using java; as in: prompt% java Hello Hello World!

for the classic first program.

If you've written an applet to be run through a browser, you can run it using a viewer, appletviewer as in: prompt% appletviewer Hello.html

which will bring up a separate window.

Simple Example ProgramsHello World as ApplicationAll the code is in a single file called Hello.java: // standard first program // runs via terminal i/o class Hello { public static void main (String[] args) { System.out.println("Hello World!"); } } Hello World as AppletFor this we need two files: one for the java code and one to define the html page from which to run it. The java code looks like: // standard first program // run as an applet import java.applet.Applet; import java.awt.*; public class HelloWorld extends Applet { public void paint (Graphics g) { g.drawString("Hello World!", 25, 25); } }

In this case, we need to inherit the Applet class for our class definition. Additionally, we overwrite a method from the class, paint, to print what we want.

We also need the companion html file, as shown in your notes to define the size of the window to open and designates the java code to be run within it.

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

How do you use AT commands in java?

s


How you do use finally keyword in java?

You use it in combination with "try" and "catch". Any commands after "finally" will be run whether there is an error or not. Cleanup commands are typically placed here.


Different basic command use in visual foxpro?

what are the basic commands in Fox Pro


Why java does not use sizeof operator?

Sizeof() is not needed because Java basic types sizes are fixed


What is the use of functions in java?

Same as in other languages. To organize commands into logical pieces. However, in Java the functions are called "methods". This is related to the fact that in Java, methods or functions are defined as part of a class.


What is the Java grammar?

"Java grammar" is the way of writing a program with correct syntax of various commands used in java language.


Can you use Java commands in the Command Prompt e.g. java and javac if you aren't logged in as an admin?

Yes. Just make sure you have the path to the programs in your PATH environment variable.


How many basic commands are there for dogs?

Basic commands are sit, stay, and lay down.


How do you connect java with visual studio?

Unfortunately, you can not use Visual Studio to edit Java. Visual Studio can be used to program: Visual Basic C# C++ ASP.NET Anyways to program Java you can use other programs as Eclipse for Java Developers


How the oracle is connected to java and visual basic?

Oracle is the company that owns Java and is partnered with Microsoft who owns Visual Basic.


What are the features of core java?

Core java refers to the core or basic concepts of the Java programming language. Things like encapsulation, inheritance, multi-threading, exception handling and other basic feature of java that comes as part of the Java standard edition forms Core Java


What is the definition of Core Java?

Core java refers to the core or basic concepts of the Java programming language. Things like encapsulation, inheritance, multi-threading, exception handling and other basic feature of java that comes as part of the Java standard edition forms Core Java