• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to compile a simple Java program  RSS feed

 
Denis Kovalyov
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Les Morgan wrote:


Hello, Les! I'm very new here and at Java. I'd tried to compile your code in cmd.exe but it showed me "error: cannot read: Junk.java     1 error". What's going on?
 
Knute Snortum
Sheriff
Posts: 4270
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Denis Kovalyov wrote:Hello, Les! I'm very new here and at Java. I'd tried to compile your code in cmd.exe but it showed me "error: cannot read: Junk.java     1 error". What's going on?

Hi Denis, and welcome to the Ranch!

Take a look here to learn how to run a Java program from the command line.
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome again

Don't use AWT components. Use Swing or JavaFX. Nobody has used AWT components for the best part of 15 years.
Don't add new questions to an old thread; I shall create a new thread from your question.
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These questions were split from this thread.
 
Sergiu Dobozi
Ranch Hand
Posts: 107
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Welcome again

Don't use AWT components. Use Swing or JavaFX. Nobody has used AWT components for the best part of 15 years.
Don't add new questions to an old thread; I shall create a new thread from your question.


I've been learning some thing from programmercreek.com, particularly from this link
http://www.programcreek.com/2014/09/top-100-classes-used-in-java-projects/
I see awt in the top 100 classes but there is no swing or javafx class there...now I'm confused
 
Paweł Baczyński
Bartender
Posts: 2074
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sergiu Dobozi wrote:I see awt in the top 100 classes but there is no swing or javafx class there...now I'm confused

There are two classes from java.awt.* packages but none of them is an AWT Component.
 
Dave Tolls
Ranch Foreman
Posts: 3056
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swing is built on top of AWT, so Color is used in both.
ActionEvent is also used in Swing as it's the most common event that occurs (see ActionListener).

And those are the only two classes there.

Have to say, I'm not sure what you can actually take away from that list, other than most code not being GUI code.
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sergiu Dobozi wrote:. . . I've been learning some thing from programmercreek.com, . . . I see awt in the top 100 classes but there is no swing or javafx class there...now I'm confused
It includes java.util.Enumeration which has hardly been used since Iterator was introduced. Some classes there are Android, which isn't really Java® and some are Junit classes, which are very frequently used in development and for testing.
I can't see any AWT components in the list. I did see one in the java.awt.event package, but that is different.
The have missed out the class most frequently used of all: String.
 
Paweł Baczyński
Bartender
Posts: 2074
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess is they analyzed import statements. And who explicitly imports java.lang.* classes?
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The same programmer creek page wrote:Among the 85, most of them are from util, lang and io.
That isn't actually correct. None of the classes they quote is in the java.lang package; there is one in java.lang.annotation and four reflection classes (which rather surprises me). They have obviously gone through the imports which means they are missing String and Exception and not counting all the constructors with
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If 69% used ArrayList and 67% used List, does that mean there are nearly 2% of projects programming to the implementation rather than to the interface?
 
Denis Kovalyov
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:
Denis Kovalyov wrote:Hello, Les! I'm very new here and at Java. I'd tried to compile your code in cmd.exe but it showed me "error: cannot read: Junk.java     1 error". What's going on?

Hi Denis, and welcome to the Ranch!

Take a look here to learn how to run a Java program from the command line.


Thanks a lot Knute! I couldn't do it with my java 5 se. but after deleting it and installing 8 se I've done it! And I've launched mooooooooo finally! But I have to keep my Java-files on the C disk. So I have another question. It's about command line. I want to keep folder with java documents on the desctop. But I can't launch essential file because i can't reach my desctop through the command line. I'm from Belarus and I have the path to the desctop like: "C:\Users\пк\Рабочий стол". When I try to write for example "cd C:\Users\пк" it always shows me "The system doesn't find specified path". I guess the problem in Russian language.
 
Knute Snortum
Sheriff
Posts: 4270
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a trick you can try.  Type just "cd " -- that's a cd and a space -- then press the tab key.  It should start displaying all your subfolders one by one.  If you don't have too many folders, that might work for you.  There is probably a way to enter Russian characters on the command line but I don't know it.
 
Denis Kovalyov
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:Here's a trick you can try.  Type just "cd " -- that's a cd and a space -- then press the tab key.  It should start displaying all your subfolders one by one.  If you don't have too many folders, that might work for you.  There is probably a way to enter Russian characters on the command line but I don't know it.

Thanks, buddy! You saved my life again!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!