Clear Screen? Using a program w/o editer

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
Sherwoodforestdude
Posts: 3
Joined: Tue Mar 09, 2004 12:26 pm

Clear Screen? Using a program w/o editer

Post by Sherwoodforestdude »

I am taking computer programming at high school and last year i took c++ and now i am taking java. I am currently working on a text based game (just with the black screen). I have two questions:

1). How do i clear the screen?

2). How would i make it so i can use it own a computer w/o the text editer


:arrow: :arrow: :arrow: :arrow: :arrow: :?:
User avatar
talleyrand
Posts: 625
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

0) Try the Java forum
1) System.out.println(""); //or do something like String clear = "\n\n\n\n..."; and call System.out.println(clear)
2) I assume you are asking how to run a java app without TP? javac MyFile.java will compile it, java MyFile (no extension even though javac will produce a MyFile.class file)
I choose to fight with a sack of angry cats.
Sherwoodforestdude
Posts: 3
Joined: Tue Mar 09, 2004 12:26 pm

Post by Sherwoodforestdude »

Thanks, i was thinking of the"\n" thing myself.
but how will i carry out step 2
"2) I assume you are asking how to run a java app without TP? javac MyFile.java will compile it, java MyFile (no extension even though javac will produce a MyFile.class file"

what do i do to create to do this appelet. The teachers (even the ap ones lol) have no clue how to do this in java


:? -Cs
User avatar
talleyrand
Posts: 625
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

Running an applet is a different animal than running a java application. Which are we talking about?

At either rate, compilation is the first step. To compile your source code (human readable file) into byte code, run it through the compiler (obviously). The command to do so is

Code: Select all

C:\sandbox>javac WizBang.java
If I were to look in that directory (dir \sandbox or explorer /e,C:\sandbox), I'd see at least two files (assuming the code was syntactically correct). My source code (WizBang.java) and the byte code (WizBang.class and any inner classes but since this is an intro course, we'll leave them be).

Now, I'm ready to run my code. If it's an application, I will invoke the java virtual machine (JVM) on it via the java command

Code: Select all

C:\sandbox>java WizBang
The rules appear to have changed (or I was ignorant of them) but to get an applet to run, in my day (2000) you needed to provide an HTML wrapper for the applet call. Then either point your browser to the HTML file or call the appletviewer. Since answering other applet questions in this forum, I did some testing and at least for me, it seems the requirement of writing the wrapper has gone to the wayside if you run the applet via the appletviewer. Thus

Code: Select all

C:\sandbox>iexplore WizBang.html
or
C:\sandbox>appletviewer WizBang.html
or
C:\sandbox>appletviewer WizBang
all seemed to produce the same results on my machine. At least, I'm pretty sure they did. I can't find where I put the files and I'm too lazy/hate applets too much to recreate them.

All of the aforementioned code assumes the current directory (.) is in the classpath and that the Java binary tools directory and possibly Internet Explorer is in your executable search path.
I choose to fight with a sack of angry cats.
User avatar
talleyrand
Posts: 625
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

Oh and WizBang.html would look something like

Code: Select all

<html>
<head>
<title>Foo</title>
</head>
<body>
   <applet code="WizBang.class" width="480" height="640" align="left" />
</body>
</html>
I choose to fight with a sack of angry cats.
Sherwoodforestdude
Posts: 3
Joined: Tue Mar 09, 2004 12:26 pm

Post by Sherwoodforestdude »

I have no clue what you said. I dont know which is your compiler or which is your file. So basically tell mewhat to do using the file MyProgram


Thanks
User avatar
ramonsky
Posts: 88
Joined: Fri Nov 14, 2003 10:54 am

Post by ramonsky »

What exactly has any of this got to do with TextPad?

If you want to learn Java, this forum is not really the right place.
Post Reply