Jump to content

Help with a basic Java thing?

Go to solution Solved by redteam4ever,

I'm not a Java programmer, but I'm sure that the paper says println - printLn.

Hey guys, I've just started school and i'm taking an introductory java class. my prof is having us run a java compiler through the command prompt on a .java file that he's given us the base code for (on paper so i think i could be just missing something there). And i cant seem to figure out what i'm doing wrong.  here's the code in the .java file

public class HelloWorld
{
	public static void main (String [] args)
	{
		System.out.printin ("Hello, World");
	}
}

vs the code on the sheet 20190110_203254.thumb.jpg.7c5a6145364aae754d3ccf546552217e.jpg

and here's the error im getting in command prompt

C:\COMP1030>javac In-Class-Assignment-1
error: invalid flag: In-Class-Assignment-1
Usage: javac <options> <source files>
use --help for a list of possible options

C:\COMP1030>cd In-Class-Assignment-1

C:\COMP1030\In-Class-Assignment-1>javac HelloWorld.java
HelloWorld.java:5: error: cannot find symbol
                System.out.printin ("Hello, World");
                          ^
  symbol:   method printin(String)
  location: variable out of type PrintStream
1 error

 

Link to comment
Share on other sites

Link to post
Share on other sites

I'm not a Java programmer, but I'm sure that the paper says println - printLn.

My heart belongs to AMD but that doesn't mean I furiously hate Intel or NVIDIA :)

 

MAIN RIG AMD Ryzen 7 1700 | ASRock Fatal1ty X370 Gaming-ITX/ac | MSI HD7950 OC 3GB | G.Skill Ripjaws V 2x8GB @ 2666MHz (Samsung D-Die) | ADATA SX8200 480GB NVMe SSD & Seagate Barracuda 120 1TB SSD & WD Black 500GB | Sharkoon QB One

 

LAPTOP Lenovo Yoga Slim 7 (14ARE05) - AMD Ryzen 5 4500U | AMD Vega 8 (Renoir) | 16GB RAM | SKHynix PC601 512GB (OEM) | 1080p 300nit non-touch display

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, redteam4ever said:

I'm not a Java programmer, but I'm sure that the paper says println - printLn.

Yep. It's print line (println) not print in (printin).

 

@TheUnderratedGamer Happens to all of us at one time or another.

 

Fan Comparisons          F@H          PCPartPicker         Analysis of Market Trends (Coming soon? Never? Who knows!)

Designing a mITX case. Working on aluminum prototypes.

Open for intern / part-time. Good at maths, CAD and airflow stuff. Dabbled with Python.

Please fill out this form! It helps a ton! https://linustechtips.com/main/topic/841400-the-poll-to-end-all-polls-poll/

Link to comment
Share on other sites

Link to post
Share on other sites

8 minutes ago, TheUnderratedGamer said:

snip


C:\COMP1030\In-Class-Assignment-1>javac HelloWorld.java
HelloWorld.java:5: error: cannot find symbol
                System.out.printin ("Hello, World");
                          ^
  symbol:   method printin(String)
  location: variable out of type PrintStream
1 error

 

Also, it can prove very useful to interpret compiler errors for your future. I've seen a lot of my friends ignore compiler messages and just look for what's wrong in their code and it takes much longer when you don't know where or what to look for.

 

That error might seem very cryptic at the first sight, but if you have the knowledge of what symbol might be (or you try googling it), you can find out where is the problem. I really want to avoid the definition what a symbol is (it wouldn't be useful), but you can think of it as anything that has a name in your program - so functions, variables, procedures, methods (depends on the language). Modern compilers also usually point to the exact spot where they "found" the error (more like when/slightly before they stopped understanding your code) and this might be misleading (especially when you make a typo), but for this type of message it's correct. Then your compiler listed what symbol cannot be found - method with name printin. That means that the compiler searched its symbol table and couldn't find it amethod with that name. I need to specify that symbol table is basically a big list of all the symbols (mostly variables and functions) that the libraries and your program contains so that compiler can verify that your program is correct and can be compiled. So the compiler was trying to tell you that method printin doesn't exist and you should look at its name.

 

I'm sorry that I got carried away with this, I'm just really happy that I made my final on compilers last week (we had to write a compiler that translates subset of FreeBASIC to custom 3-address code for a project in that course).

 

20 minutes ago, TheUnderratedGamer said:

well. thanks guys, thread is over rip my life. im gonna go cry in a corner now

It happens to the best of us :) Don't let this stop you, later down the line you will definitely forget a semi-colon somewhere and that is going to be a wild hunt ;) But semantic errors are the worst - you will compile the code, it compiles, but does something else and you don't know why.

My heart belongs to AMD but that doesn't mean I furiously hate Intel or NVIDIA :)

 

MAIN RIG AMD Ryzen 7 1700 | ASRock Fatal1ty X370 Gaming-ITX/ac | MSI HD7950 OC 3GB | G.Skill Ripjaws V 2x8GB @ 2666MHz (Samsung D-Die) | ADATA SX8200 480GB NVMe SSD & Seagate Barracuda 120 1TB SSD & WD Black 500GB | Sharkoon QB One

 

LAPTOP Lenovo Yoga Slim 7 (14ARE05) - AMD Ryzen 5 4500U | AMD Vega 8 (Renoir) | 16GB RAM | SKHynix PC601 512GB (OEM) | 1080p 300nit non-touch display

Link to comment
Share on other sites

Link to post
Share on other sites

Thanks my dude, Now i'm dealing with this

C:\COMP1030\In-Class-Assignment-1>java HelloWorld
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: HelloWorld has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

I've been trying to find a newer version of the Java Runtime Environment but That doesn't seem to work. I also really appreciate the help. I'm sure these early stages are going to be the worst part for me

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, TheUnderratedGamer said:

Thanks my dude, Now i'm dealing with this


C:\COMP1030\In-Class-Assignment-1>java HelloWorld
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: HelloWorld has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

I've been trying to find a newer version of the Java Runtime Environment but That doesn't seem to work. I also really appreciate the help. I'm sure these early stages are going to be the worst part for me

Never mind, fixed it

 

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, TheUnderratedGamer said:

Never mind, fixed it

 

Lol, thanks for joining my boat of screwing up on typos. I has a GLSL chunk that i spelled "position" as "postion"

Link to comment
Share on other sites

Link to post
Share on other sites

The best way to program java is to get an ide like eclipse or netbeans

Link to comment
Share on other sites

Link to post
Share on other sites

On 1/11/2019 at 11:47 AM, Mephi00 said:

The best way to program java is to get an ide like eclipse or netbeans

Yes but for such easy one class solutions you can also do it with a simple editor like notepad++ that has syntax highlighting so you can detect syntax errors, missing symbols etc. easy.  For larger and more complex projects you should for sure go trough the process of installing and customizing an IDE like eclipse, netbeans or intelliJ to name the most popular ones for java. 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×