Discuss Scratch

emeralddog
Scratcher
100+ posts

How to run java written on notepad files?

Do I have to save it as .jar or something, and then how do I execute the file?
ChocolatePi
Scratcher
1000+ posts

How to run java written on notepad files?

You should use an IDE rather than compiling java files yourself.

Beside from that, you do not seem to have learned what you already know from a reliable source. There are tons of bad java tutorials out there, and I'd recommend The Java Tutorials, written by the very people who invented Java.
emeralddog
Scratcher
100+ posts

How to run java written on notepad files?

ChocolatePi wrote:

You should use an IDE rather than compiling java files yourself.

Beside from that, you do not seem to have learned what you already know from a reliable source. There are tons of bad java tutorials out there, and I'd recommend The Java Tutorials, written by the very people who invented Java.
Sounds good, what is an IDE? Do I need to download it? Where do I download it?
ChocolatePi
Scratcher
1000+ posts

How to run java written on notepad files?

emeralddog wrote:

ChocolatePi wrote:

You should use an IDE rather than compiling java files yourself.

Beside from that, you do not seem to have learned what you already know from a reliable source. There are tons of bad java tutorials out there, and I'd recommend The Java Tutorials, written by the very people who invented Java.
Sounds good, what is an IDE? Do I need to download it? Where do I download it?
An IDE means ‘Integrated Development Environment’. It basically means that you just write the code and it runs it for you.
emeralddog
Scratcher
100+ posts

How to run java written on notepad files?

ChocolatePi wrote:

emeralddog wrote:

ChocolatePi wrote:

You should use an IDE rather than compiling java files yourself.

Beside from that, you do not seem to have learned what you already know from a reliable source. There are tons of bad java tutorials out there, and I'd recommend The Java Tutorials, written by the very people who invented Java.
Sounds good, what is an IDE? Do I need to download it? Where do I download it?
An IDE means ‘Integrated Development Environment’. It basically means that you just write the code and it runs it for you.
Where can I download one of these?
ChocolatePi
Scratcher
1000+ posts

How to run java written on notepad files?

Here, here, or here.
Zeusking19
Scratcher
500+ posts

How to run java written on notepad files?

I should mention that ChocolatePi linked to the Eclipse Foundation, and not the Eclipse Project. I'll link to the download page, which is here.
drmcw
Scratcher
1000+ posts

How to run java written on notepad files?

Just to answer your initial question, you have to compile the your java notepad file using javac which will then create a file that can be run by the java runtime; java. As already mentioned find a good tutorial and follow its instructions. IDE's are nice but also hide a lot of stuff that is useful to know.
MathWizz
Scratcher
100+ posts

How to run java written on notepad files?

Just remember, Google is your friend when you need questions like this answered. http://lmgtfy.com/?q=How+to+run+java+written+on+notepad+files%3F
MegaApuTurkUltra
Scratcher
1000+ posts

How to run java written on notepad files?

MathWizz wrote:

Just remember, Google is your friend when you need questions like this answered. http://lmgtfy.com/?q=How+to+run+java+written+on+notepad+files%3F
This.

You don't need an IDE, although it's really helpful (syntax highlighting and setting up runtimes for you). However you can also
# compile it
javac MyClass.java
# run it
java MyClass
I have no idea how to make jars outside of eclipse, but I bet there's a command line tool for that too. You don't need them for testing though, only for distributing code (it's like a zip - stores tons of files inside one file).
emeralddog
Scratcher
100+ posts

How to run java written on notepad files?

MathWizz wrote:

Just remember, Google is your friend when you need questions like this answered. http://lmgtfy.com/?q=How+to+run+java+written+on+notepad+files%3F
I'm not even going to look at that link let me google that for you, actually I will anyway
emeralddog
Scratcher
100+ posts

How to run java written on notepad files?

Ok, this is all quite confusing, I think I will just stick with the tutorials I have been shown.
CatsUnited
Scratcher
1000+ posts

How to run java written on notepad files?

emeralddog wrote:

Ok, this is all quite confusing, I think I will just stick with the tutorials I have been shown.
Are you sure?
drmcw
Scratcher
1000+ posts

How to run java written on notepad files?

MegaApuTurkUltra wrote:

I have no idea how to make jars outside of eclipse, but I bet there's a command line tool for that too.
Correct and its called jar!
RenataCouncil
New Scratcher
3 posts

How to run java written on notepad files?

Create a temporary folder C:\mywork. Using Notepad or another text editor, create a small Java file HelloWorld.java
Run Command Prompt (found under All Programs/Accessories in the Start menu).Run Command Prompt (found under All Programs/Accessories in the Start menu). Type
C:\> cd \mywork
This makes C:\mywork the current directory.
C:\mywork> dir
This displays the directory contents. You should see HelloWorld.java among the files.
C:\mywork> set path=%path%;C:\Program Files\Java\jdk1.5.0_09\bin
This tells the system where to find JDK programs.
C:\mywork> javac HelloWorld.java
This runs javac.exe, the compiler. You should see nothing but the next system prompt…
C:\mywork> dir
javac has created the HelloWorld.class file. You should see HelloWorld.java and HelloWorld.class among the files.
C:\mywork> java HelloWorld
This runs the Java interpreter. You should see the program output:

Visit:http://laustan.com/
liam48D
Scratcher
1000+ posts

How to run java written on notepad files?

RenataCouncil wrote:

Create a temporary folder C:\mywork. Using Notepad or another text editor, create a small Java file HelloWorld.java
Run Command Prompt (found under All Programs/Accessories in the Start menu).Run Command Prompt (found under All Programs/Accessories in the Start menu). Type
C:\> cd \mywork
This makes C:\mywork the current directory.
C:\mywork> dir
This displays the directory contents. You should see HelloWorld.java among the files.
C:\mywork> set path=%path%;C:\Program Files\Java\jdk1.5.0_09\bin
This tells the system where to find JDK programs.
C:\mywork> javac HelloWorld.java
This runs javac.exe, the compiler. You should see nothing but the next system prompt…
C:\mywork> dir
javac has created the HelloWorld.class file. You should see HelloWorld.java and HelloWorld.class among the files.
C:\mywork> java HelloWorld
This runs the Java interpreter. You should see the program output:

Visit:http://laustan.com/
This is for Windows - here's a quick tutorial for Mac.

You'll need Java on your computer, I'm assuming you've already gotten that.

Open up Terminal - to do this just press command-space to open up spotlight search, then type in Terminal and open up the app it gives you.

Type in cd with a space after it, then drag in the folder that your .java file is located in. It should look like this:
cd /Users/me/Documents/Java\ Programs/
Then, type in the command to compile a java program - javac, which stands for Java Compile. Type in the name of your java file, including the extension. It should look like this:
javac hello_world.java
To confirm it's working, type in this command:
ls *.class
This lists all files which have the extension .class. If it's there, just type in java (My File).class:
java hello_world.class
Here's the end code:
cd /Users/me/Documents/Java\ Programs/ # Change directory to folder containing hello_world.java
javac hello_world.java                 # Compile hello_world.java to hello_world.class
java hello_world.class                 # Run hello_world.class
MegaApuTurkUltra
Scratcher
1000+ posts

How to run java written on notepad files?

liam48D wrote:

RenataCouncil wrote:

Create a temporary folder C:\mywork. Using Notepad or another text editor, create a small Java file HelloWorld.java
Run Command Prompt (found under All Programs/Accessories in the Start menu).Run Command Prompt (found under All Programs/Accessories in the Start menu). Type
C:\> cd \mywork
This makes C:\mywork the current directory.
C:\mywork> dir
This displays the directory contents. You should see HelloWorld.java among the files.
C:\mywork> set path=%path%;C:\Program Files\Java\jdk1.5.0_09\bin
This tells the system where to find JDK programs.
C:\mywork> javac HelloWorld.java
This runs javac.exe, the compiler. You should see nothing but the next system prompt…
C:\mywork> dir
javac has created the HelloWorld.class file. You should see HelloWorld.java and HelloWorld.class among the files.
C:\mywork> java HelloWorld
This runs the Java interpreter. You should see the program output:

Visit:http://laustan.com/
This is for Windows - here's a quick tutorial for Mac.

You'll need Java on your computer, I'm assuming you've already gotten that.

Open up Terminal - to do this just press command-space to open up spotlight search, then type in Terminal and open up the app it gives you.

Type in cd with a space after it, then drag in the folder that your .java file is located in. It should look like this:
cd /Users/me/Documents/Java\ Programs/
Then, type in the command to compile a java program - javac, which stands for Java Compile. Type in the name of your java file, including the extension. It should look like this:
javac hello_world.java
To confirm it's working, type in this command:
ls *.class
This lists all files which have the extension .class. If it's there, just type in java (My File).class:
java hello_world.class
Here's the end code:
cd /Users/me/Documents/Java\ Programs/ # Change directory to folder containing hello_world.java
javac hello_world.java                 # Compile hello_world.java to hello_world.class
java hello_world.class                 # Run hello_world.class
1. That's not correct class naming. It should be CapitalizedCamelCase
2. The command is
java hello_world
# NOT java hello_world.class
emeralddog
Scratcher
100+ posts

How to run java written on notepad files?

RenataCouncil wrote:

Create a temporary folder C:\mywork. Using Notepad or another text editor, create a small Java file HelloWorld.java
Run Command Prompt (found under All Programs/Accessories in the Start menu).Run Command Prompt (found under All Programs/Accessories in the Start menu). Type
C:\> cd \mywork
This makes C:\mywork the current directory.
C:\mywork> dir
This displays the directory contents. You should see HelloWorld.java among the files.
C:\mywork> set path=%path%;C:\Program Files\Java\jdk1.5.0_09\bin
This tells the system where to find JDK programs.
C:\mywork> javac HelloWorld.java
This runs javac.exe, the compiler. You should see nothing but the next system prompt…
C:\mywork> dir
javac has created the HelloWorld.class file. You should see HelloWorld.java and HelloWorld.class among the files.
C:\mywork> java HelloWorld
This runs the Java interpreter. You should see the program output:

Visit:http://laustan.com/
I'm seriously confused, please can you explain that again to me, as if I have never even written a word of code in java (which I haven't by the way.) Current directory???
Zeusking19
Scratcher
500+ posts

How to run java written on notepad files?

emeralddog wrote:

RenataCouncil wrote:

Create a temporary folder C:\mywork. Using Notepad or another text editor, create a small Java file HelloWorld.java
Run Command Prompt (found under All Programs/Accessories in the Start menu).Run Command Prompt (found under All Programs/Accessories in the Start menu). Type
C:\> cd \mywork
This makes C:\mywork the current directory.
C:\mywork> dir
This displays the directory contents. You should see HelloWorld.java among the files.
C:\mywork> set path=%path%;C:\Program Files\Java\jdk1.5.0_09\bin
This tells the system where to find JDK programs.
C:\mywork> javac HelloWorld.java
This runs javac.exe, the compiler. You should see nothing but the next system prompt…
C:\mywork> dir
javac has created the HelloWorld.class file. You should see HelloWorld.java and HelloWorld.class among the files.
C:\mywork> java HelloWorld
This runs the Java interpreter. You should see the program output:

Visit:http://laustan.com/
I'm seriously confused, please can you explain that again to me, as if I have never even written a word of code in java (which I haven't by the way.) Current directory???

If you are having difficulty with this perhaps you should get an IDE or learn about Command Prompt/Terminal first
emeralddog
Scratcher
100+ posts

How to run java written on notepad files?

Zeusking19 wrote:

emeralddog wrote:

RenataCouncil wrote:

Create a temporary folder C:\mywork. Using Notepad or another text editor, create a small Java file HelloWorld.java
Run Command Prompt (found under All Programs/Accessories in the Start menu).Run Command Prompt (found under All Programs/Accessories in the Start menu). Type
C:\> cd \mywork
This makes C:\mywork the current directory.
C:\mywork> dir
This displays the directory contents. You should see HelloWorld.java among the files.
C:\mywork> set path=%path%;C:\Program Files\Java\jdk1.5.0_09\bin
This tells the system where to find JDK programs.
C:\mywork> javac HelloWorld.java
This runs javac.exe, the compiler. You should see nothing but the next system prompt…
C:\mywork> dir
javac has created the HelloWorld.class file. You should see HelloWorld.java and HelloWorld.class among the files.
C:\mywork> java HelloWorld
This runs the Java interpreter. You should see the program output:

Visit:http://laustan.com/
I'm seriously confused, please can you explain that again to me, as if I have never even written a word of code in java (which I haven't by the way.) Current directory???

If you are having difficulty with this perhaps you should get an IDE or learn about Command Prompt/Terminal first
Ok then, thanks

Powered by DjangoBB