Iryna Chakraborty

Greenhorn
+ Follow
since Dec 01, 2019
Iryna likes ...
IntelliJ IDE Postgres Database Java
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
11
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Iryna Chakraborty

Hello, everybody!

I have some doubts about Web development books with Java. Several years ago I was studying web using the book www.amazon.in. But it was in 2015. Are there something new and somehow improved according to modern features used in web with JAVA and with other web-technologies. Maybe your are using some other books. Thanks for your replies.
1 month ago

Balajee Reva wrote:Hi All,

I passed 1z0-808 exam with 92% on 21st August.

1) Kathy Sierra BOOK
2)Enthuware exam



Hi, Balajee Reva,
Congrats!

I have a  question - did you have a working experience before passing the exam? Or just prepared for the exam and passed it?

Campbell Ritchie wrote:Opinions will doubtless vary, but Java8 is still regarded as a current version, so it is probably an exaggeration to call 1Z0‑808 outdated.
Do you need a new cert to find a job? Has somebody told you to pass the Java11 exams?


Campbell Ritchie, if I don't have the strict order to pass Java 11 exam and I need to find a job, will it be useful to pass Java 8?

Campbell Ritchie wrote:This question would fit better in a different forum, so I shall move it.

Search→“Utility class Scanner”→choose fora to search (ctrl‑click for several)→scroll down→user name

I hope that helps; if not, ask for more information.

[additonal} This discussion split from here. I didn't find much with those search terms; maybe Scanner hasNextInt nextInt will produce more hits.



Thank you!
9 months ago

Randy Tong wrote:What are all num referring to ?



As I see it: second variable 'num' in line 6 - is initialized with self assignment. It means assignments of a variable to itself.
So, it is redundant and should be removed as it doesn't have any effect and it is completely unnecessary.
9 months ago

Campbell Ritchie wrote:I would prefer to use a utility class for keyboard input. That class can hide the Scanner instance and also take care of that gotcha about nextLine(). You may not have the time to write a utility class, but if you search my posts for “Scanner utility class” you will eventually find enough parts to assemble a complete class (an one serious error).


Campbell Ritchie, can you explain how to search personal answers? To open just a list from a user - it's clear, but to search among all the posts you have - in what way?
9 months ago

Jj Roberts wrote:I'm glad you know more about Windows than me  . My exposure to Windows has been very limited. More than happy to stay on Ubuntu  


I can say the same thing about my knowledge of Ubuntu and others from Linux.
9 months ago
Jj Roberts, Knute Snortum,

Thank you very much! Now everything is working perfectly well.

The problem was that I tried to run it not from the source folder (src) but being inside it Now I know how to run it correctly.

Jj Roberts wrote:It does work if you are running it from the correct directory. What Knute is saying is that if your folders looked like my/folder/foo/bar/Zoo.java you would have to run

from the 'folder' directory. You have to run the commands from the directory which contains your package. In your case your file is at com/cha/iru/Zoo.java. What you need to do is navigate to the folder which com is in. Go and do that. Once you are in com's parent folder, you will need to run
(of course, if you are on Windows, the slashes go the other way).



PS Jj Roberts, slashes don't play important role, it works both ways. But thanks for a remark.
10 months ago

Knute Snortum wrote:Say you are in the directory my/folder/ and your Java code has a package statement package foo.bar;, then the commands you want to issue from my/folder are

   javac foo/bar/Zoo.java
   java foo.bar.Zoo one two

The package statement translates into a folder path of foo/bar.  javac take a path to a file.  java takes a fully qualified class name.


Using package it doesn't work. It works only when class is in the source folder directly. Why is it so?
10 months ago

Junilu Lacar wrote:Try changing directory to ..\first_project\src then do what Dave said to do.

If that doesn't work, cd to ..\first_project\out -- check to see if that's where your .class files are after you compile. If you're compiling from the command line, your class files might be under the ..\src directory though.



Thank you, Junilu Lacar!

It works after putting class just in source folder without a package as in the book's example:

javac Zoo.java
java Zoo fox fox2


output:

fox
fox2


Can you explain me why is it so? I don't understand why it was working in cmd as "java Zoo.java" using package and without it it works as in the example from the book.
10 months ago

Dave Tolls wrote:Where are you executing the command from?

Where is the Zoo.class file?

What exact command are you executing?



1. I'm executing from the Command Prompt
2. the Zoo.class file is in the package 'com.cha.iru'
3. first one - javac Zoo.java
   second one - java com.cha.iru.Zoo

Error is the same:

Error: Could not find or load main class com.cha.iru.Zoo
Caused by: java.lang.ClassNotFoundException: com.cha.iru.Zoo
10 months ago

Dave Tolls wrote:Which shows the esact issue, that Campbell mentioned.

Your Zoo class is in a package (com.cha.iru) which means its full class name is com.cha.iru.Zoo, and you would be expected to execute the compile file from the root directory for your package structure (ie the directory that contains the com folder).  And the command would be:
java com.cha.iru.Zoo something something


Adding full path to class didn't give any changes
10 months ago

Campbell Ritchie wrote:Welcome to the Ranch

I suggest you show us the code you are running please. “Wrong name” errors are often caused by having a package name in the code and putting the .class file in a folder with a name different from its package. As JJ says, you can run an uncompiled single XYZ.java file in Java11+; the fact that it isn't complaining suggests your .class files have a different name. Please copy'n'paste the text from your command line in future because it is much easier to handle like that. I can't see the screenshot from here, and had to open your post twice.



Thank you, Campbell

This is my code and screen of the project structure:
10 months ago

Jj Roberts wrote:Hello and welcome to the Ranch!

In Java 11 you can compile and run a single-file program by passing it directly to the java tool. That is what you are doing the second time.

It seems odd that it works that way, but says Zoo is the wrong name when you use javac and then java. What happens when you give it different arguments, like 'giraffe zebra'? What does your project's directory structure look like?



I'm glad to be here Thanks. Giving other parameters changed nothing. Here's a screen:
10 months ago

Hi, coderanchers! I'm trying to run the code from cmd.
In the book "OCA Study Guide" there's an explanation how to run it:

$ javac Zoo.java
$ java Zoo Bronx Zoo

The output is what you might expect:
Bronx
Zoo


In my case I have this:

Why it goes on without errors by adding ".java" for the second time?
10 months ago