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
Clear Screen? Using a program w/o editer
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
- Posts: 3
- Joined: Tue Mar 09, 2004 12:26 pm
- talleyrand
- Posts: 624
- Joined: Mon Jul 21, 2003 6:56 pm
- Location: Kansas City, MO, USA
- Contact:
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)
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.
-
- Posts: 3
- Joined: Tue Mar 09, 2004 12:26 pm
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
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
- talleyrand
- Posts: 624
- Joined: Mon Jul 21, 2003 6:56 pm
- Location: Kansas City, MO, USA
- Contact:
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
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
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
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.
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
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
Code: Select all
C:\sandbox>iexplore WizBang.html
or
C:\sandbox>appletviewer WizBang.html
or
C:\sandbox>appletviewer WizBang
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.
- talleyrand
- Posts: 624
- Joined: Mon Jul 21, 2003 6:56 pm
- Location: Kansas City, MO, USA
- Contact:
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.
-
- Posts: 3
- Joined: Tue Mar 09, 2004 12:26 pm