#What's the name of the structure like its: "foo.bar.class"
1 messages ยท Page 1 of 1 (latest)
<@&987246964494204979> please have a look, thanks.
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
Here is an AI assisted attempt to answer your question ๐ค. Maybe it helps! In any case, a human is on the way ๐. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.
The structure you are referring to is called a package structure in Java.
fully qualified name class type
it kinda depends on the context
java.util.Scanner here u have a package and then the name of the class
but nothing holds u back from naming ur classes with lower case
and then it could also be inner classes
such as in java.util.ArrayList.Iterator
Iterator being an inner class of ArrayList
and java.util being the package its in
but yeah, in the end its called the "fully qualified name" of a class
like its "full address"
wait, is the "java.util.Scanner" just a representation of the the equivlent file directory .\java\util\Scanner?
yes
packages are supposed to be represented in file hierachy
(theres a flag to tell javac to ignore that, but still)
so if i have my class like this .\build\MainClass it would be like build.MainClass
no
packages are first and foremost a concept in ur java code
when u create a class, the first line denotes the package its in
package foo.bar;
public class Test {
...
}
the Test class is in the package foo.bar
its full name is foo.bar.Test
and javac wants u to represent this package hierarchy also in folder structure
so ur supposed to put it in a foo/bar/Test.java
so it's exclusively used for packages or is this thing use for other things?
but that doesnt mean that all folders are automatically packages
the part that makes a package is this first line in the class
hm
packages are part of accessibility control
could i ask you a question about manifests?
u know, theres public, protected, private and if u dont write anything, u get "package-visible"
so packages are for package-visibility
and ultimately are used to organize ur code in a meaningful way
similar to folders
hence why ur also supposed to represent them with folders
just do it
ay
right now i've had troble getting my .jar file to world, as every time i run it using java -jar helloWorld.jar it responds with "could not find main class"
What i use to compile from .class \Test build> jar cfm build-1.jar .\build\Manifest.txt .\build\helloWorld.class
i think it's a issue about the manifest pointing the wrong way, as rn i have it as main-class: helloWorld
I uploaded your attachments as Gist.
Here is an example of a Java JAR manifest file with a main class entry:
Manifest-Version: 1.0
Main-Class: com.example.MainClass
In this example, the main class entry is specified as com.example.MainClass. Replace com.example.MainClass with the fully qualified name of your main class.
ur class needs to be public
and perhaps u also need to put it in a package
im not sure if jars work with the "default package"
btw import java.lang.Math; is obsolete. anything from the java.lang package is auto-imported implicitly
and this myObj.close(); is technically a bug
u must not close scanners tied to System.in
only if they are tied to files or similar
god i know so little about java
dont worry
How can i do this? just add the public keyword at line 4?
yes. public class Foo {
it giving the error: say the public type needs to be it's own file
then u did a mistake
gonna share the code
or ur misinterpreting the error
would be good if u share the actual error message
same as class...
i doubt
look at the case as well
u likely called it HelloWorld.java or helloworld.java or sth
but not helloWorld.java
Well i use the class name for the .class file
so helloWorld.class
exact same
can u please just share a full screenshot of ur IDE window
with the class name, the code and the error message in it
full screenshot
Sc
a full screenshot please
of ur entire IDE window
but i can already see that u called it 0.java
instead of helloWorld.java
a general note: visual studio code is a really bad IDE for writing java code. every second user asking here for help with some IDE related problem is using VSC
yes