Discuss Scratch

CatsUnited
Scratcher
1000+ posts

Compiling Java code

I''m trying to compile Java code using https://docs.oracle.com/javase/tutorial/getStarted/cupojava/win32.html
I've noticed that I had a couple of errors:

The first one was in the common problems and their solutions. The other one didn't seem to be there.

The common problems page said:
If you receive this error, Windows cannot find the compiler (javac).

Here's one way to tell Windows where to find javac. Suppose you installed the JDK in “C:\jdk1.8.0”. At the prompt you would type the following command and press Enter:

C:\jdk1.8.0\bin\javac HelloWorldApp.java
If you choose this option, you'll have to precede your javac and java commands with C:\jdk1.8.0\bin\ each time you compile or run a program. To avoid this extra typing, consult the section Updating the PATH variable in the JDK 8 installation instructions.
My browser / operating system: Windows 8.1, Chrome 41.0.2272.118, Flash 17.0 (release 0)

EDIT: The page says to create a .class file, but that's throwing up one of the errors.

Last edited by CatsUnited (April 15, 2015 03:05:45)


bottom text
Harakou
Scratch Team
1000+ posts

Compiling Java code

Like the tutorial says, you need to either add the javac command to your PATH variable, or use the absolute path of the command. Are you sure you have the right path? The jre is usually installed to your program files folder, not the root.
MegaApuTurkUltra
Scratcher
1000+ posts

Compiling Java code

You should not be compiling java yourself.

Use an IDE such as Eclipse (which I recommend, but is advanced/complicated), IntelliJ Idea (which is kinda advanced, I think), or NetBeans (which is easy). They do all the hard work like compiling and setting up runtimes, so you can focus on developing

You don't even need java on your path. Eclipse (at least) will detect it automagically, and since eclipse has its own java compiler (to provide better error reporting no doubt), you don't even need a jdk.

Last edited by MegaApuTurkUltra (April 15, 2015 12:19:55)


$(".box-head")[0].textContent = "committing AT crimes since $whenever"
CatsUnited
Scratcher
1000+ posts

Compiling Java code

MegaApuTurkUltra wrote:

You should not be compiling java yourself.

Use an IDE such as Eclipse (which I recommend, but is advanced/complicated), IntelliJ Idea (which is kinda advanced, I think), or NetBeans (which is easy). They do all the hard work like compiling and setting up runtimes, so you can focus on developing
yey. I can't run NetBeana though because my computer is too weak - can I use Eclipse?

bottom text
ChocolatePi
Scratcher
1000+ posts

Compiling Java code

CatsUnited wrote:

MegaApuTurkUltra wrote:

You should not be compiling java yourself.

Use an IDE such as Eclipse (which I recommend, but is advanced/complicated), IntelliJ Idea (which is kinda advanced, I think), or NetBeans (which is easy). They do all the hard work like compiling and setting up runtimes, so you can focus on developing
yey. I can't run NetBeana though because my computer is too weak - can I use Eclipse?
I think NetBeans is the most lightweight Java IDE available.
CatsUnited
Scratcher
1000+ posts

Compiling Java code

ChocolatePi wrote:

CatsUnited wrote:

MegaApuTurkUltra wrote:

You should not be compiling java yourself.

Use an IDE such as Eclipse (which I recommend, but is advanced/complicated), IntelliJ Idea (which is kinda advanced, I think), or NetBeans (which is easy). They do all the hard work like compiling and setting up runtimes, so you can focus on developing
yey. I can't run NetBeana though because my computer is too weak - can I use Eclipse?
I think NetBeans is the most lightweight Java IDE available.
And my computer can't run it. That's why I'm using command line but it doesn't work.

bottom text
cobraguy
Scratcher
1000+ posts

Compiling Java code

CatsUnited wrote:

ChocolatePi wrote:

CatsUnited wrote:

MegaApuTurkUltra wrote:

You should not be compiling java yourself.

Use an IDE such as Eclipse (which I recommend, but is advanced/complicated), IntelliJ Idea (which is kinda advanced, I think), or NetBeans (which is easy). They do all the hard work like compiling and setting up runtimes, so you can focus on developing
yey. I can't run NetBeana though because my computer is too weak - can I use Eclipse?
I think NetBeans is the most lightweight Java IDE available.
And my computer can't run it. That's why I'm using command line but it doesn't work.
Actually, Eclipse can be the lightest IDE if you install the parts separately. I found this a while ago and have always installed Eclipse that way ever since. Simply go here and choose a version of Eclipse. I usually choose the Latest Release version. Then just follow the steps provided in the Stackoverflow post.

Last edited by cobraguy (April 15, 2015 12:50:06)

CatsUnited
Scratcher
1000+ posts

Compiling Java code

cobraguy wrote:

CatsUnited wrote:

ChocolatePi wrote:

CatsUnited wrote:

MegaApuTurkUltra wrote:

You should not be compiling java yourself.

Use an IDE such as Eclipse (which I recommend, but is advanced/complicated), IntelliJ Idea (which is kinda advanced, I think), or NetBeans (which is easy). They do all the hard work like compiling and setting up runtimes, so you can focus on developing
yey. I can't run NetBeana though because my computer is too weak - can I use Eclipse?
I think NetBeans is the most lightweight Java IDE available.
And my computer can't run it. That's why I'm using command line but it doesn't work.
Actually, Eclipse can be the lightest IDE if you install the parts separately. I found this a while ago and have always installed Eclipse that way ever since. Simply go here and choose a version of Eclipse. I usually choose the Latest Release version. Then just follow the steps provided in the Stackoverflow post.
Okay thanks.

bottom text
MathWizz
Scratcher
100+ posts

Compiling Java code

Actually, compiling Java via command prompt is fine if you're only doing it with a small project and is a great way to learn how the compiling system works.

running Chromium 42.0.2311.90 with Flash Player 15.0.0.189 on Arch Linux 3.19.5-1-ck
MathWizzJsScratch && sb.js & Amber (coming soon! maybe)

Powered by DjangoBB

Standard | Mobile