#My class is not running

21 messages · Page 1 of 1 (latest)

austere pond
#

I am currently using Windows 11 and I'm trying to setup java for classes. I'm using Windows PowerCell and Notepad for my coding. when I tried to compile, I got the error message "PS C:\Users\tcgqw\Downloads\firstcode. java> javac Firstcode. java
Firstcode. java:1: error: '{' expected
public class Firstcode. java {
1 error
I attached an image of my code to the post

I want to have it save the class file so it could print, but I don't know why it isn't working it just makes an error no matter how I edit the class or file name
Code as text
`public class Firstcode.java {

public static void main (String [] args) {
int wage;

  wage = 20;                        

  System.out.print("Salary is ");       
  System.out.println(wage * 40 * 52);   

}
}`

cosmic jacinthBOT
#

Hello! Thank you for your question. Unfortunately, your post is missing some crucial information. To help you best, please provide the following:

  • A detailed description of the problem: What are you trying to achieve? What is the expected behavior, and what is actually happening?
  • Relevant code: Please share the code related to the issue. Use markdown formatting to make it readable (e.g., java your code here ).
  • Error messages: If you're encountering any errors, please include the full error messages.
  • Context: Include information about your development environment (IDE, operating system, etc.) and any steps you've already taken to troubleshoot the issue.

The more information you provide, the better we can assist you!

#

-# Java @fading comet

soft prism
#

Why is your class called Firstcode.java

austere pond
vivid smelt
#

Then

javac Firstcode.java

#

Then

java Firstcode

#

I suspect you forgot the .java ending when running javac

#

So the java compiler didnt know Firstcode was a .java file

austere pond
vivid smelt
#

Then i really dont know

#

Is your file itself called Firstcode.java? And the classname is Firstcode?

#

Its not Firstcode.java.java or something

#

Maybe also just save the edits and try again, very strange

#

🤔

austere pond
#

I really hope this doesn’t happen again lol

vivid smelt
#

which ide did you get?

#

i think IntelliJ autosaves for you, so does Eclipse (i think) 💯