Help building basic println/string out program.

  • (2 Pages)
  • +
  • 1
  • 2

23 Replies - 830 Views - Last Post: 10 April 2012 - 10:59 PM Rate Topic: -----

#16 FEAST  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 43
  • Joined: 10-April 12

Re: Help building basic println/string out program.

Posted 10 April 2012 - 07:48 PM

So this would be correct then?

public class global
{

	public static void main(String[] args)
	{

		
	
		String Bang = "Java program\n"
					+ "{ and }\n"
					+ "yeee\n"
					+ "\n"
					+ "System.out.println\n"
					+ "( and )\n"
					+ "String\n"
					+ "\"weeee(mmk\\\" instead!)";
					
		System.out.println(Bang);
	
		
	}
}


Also, I need to compile from notepad++ at the moment - it is required. I will be moving to eclipse soon.

If you have any info on how to do that, please....lol

I have read 3-4 different things on how to compile java from here and none of them are the same, I don't really understand them, and none seem to work...
Was This Post Helpful? 0
  • +
  • -

#17 floppyspace  Icon User is offline

  • D.I.C Regular

Reputation: 48
  • View blog
  • Posts: 254
  • Joined: 04-February 10

Re: Help building basic println/string out program.

Posted 10 April 2012 - 08:05 PM

yes your program compiles now.

notepad++ is the bomb so use it for now but get eclipse and just cut from notepad++ to eclipse even if it is just for testing purposes (you will be using it eventually anyway as you said).

Having to recompile a code every time you make small alterations can become tedious especially if your dealing with small mathematical errors.

To get you going you need to use javac to compile a program, try googling it. It is lengthy to explain so perhaps check this it may be ok.

or for more depth this.

hope this puts you on the right track (have own assignments to finish now :P)

This post has been edited by floppyspace: 10 April 2012 - 08:10 PM

Was This Post Helpful? 0
  • +
  • -

#18 FEAST  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 43
  • Joined: 10-April 12

Re: Help building basic println/string out program.

Posted 10 April 2012 - 09:05 PM

I have downloaded eclipse, installed the JDK v7 update 3, and began using it. I opened a new java project, created a new file, and pasted in the code.

When I click run > java application it gives me the error "Selection does not contain a main type".

What could my problem be?
Was This Post Helpful? 0
  • +
  • -

#19 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Help building basic println/string out program.

Posted 10 April 2012 - 09:09 PM

You can look here: http://websitenotebo...ntain-main.html
Was This Post Helpful? 0
  • +
  • -

#20 FEAST  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 43
  • Joined: 10-April 12

Re: Help building basic println/string out program.

Posted 10 April 2012 - 09:13 PM

Uh, okay. So. I read that. And I basically understand none of it.

Class file? Is that what I should be putting my code in? Where should the code file be relative to the project folder?

I have:

Project folder
>src
>JRE System Library
>My code file

Note that my code file is a standard file...
Was This Post Helpful? 0
  • +
  • -

#21 floppyspace  Icon User is offline

  • D.I.C Regular

Reputation: 48
  • View blog
  • Posts: 254
  • Joined: 04-February 10

Re: Help building basic println/string out program.

Posted 10 April 2012 - 10:00 PM

a few ways available one is

right click your new java package

go to new and then select class in the list

in the menu add a name were it says name.

if you do not have the main method then add it by selecting the stubs create option.

then click finish and paste your code in this window/ newley created class.

go to top and click the run button go through confirmations to run and vola

note- your class name must be the same as the file name if it highlights as red right click on the x and it will ask you to change name or offer some other options depending on the problem.

This post has been edited by floppyspace: 10 April 2012 - 10:01 PM

Was This Post Helpful? 0
  • +
  • -

#22 FEAST  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 43
  • Joined: 10-April 12

Re: Help building basic println/string out program.

Posted 10 April 2012 - 10:14 PM

OMFG it works!

public class global {

	
	public static void main(String[] args) {

		String Bang = "A well-formed Java program has\n"
				+ "a main method with { and }\n"
				+ "braces.\n"
				+ "\n"
				+ "A System.out.prinln statement\n"
				+ "has ( and ) and usually a\n"
				+ "String that starts and ends\n"
				+ "with a \" character.(But we type \\\" instead!)";
				
	System.out.println(Bang);
	
	}

}


Was This Post Helpful? 1
  • +
  • -

#23 floppyspace  Icon User is offline

  • D.I.C Regular

Reputation: 48
  • View blog
  • Posts: 254
  • Joined: 04-February 10

Re: Help building basic println/string out program.

Posted 10 April 2012 - 10:32 PM

View PostFEAST, on 10 April 2012 - 10:14 PM, said:

OMFG it works!


Has some funk too hey :)

Happy coding
Was This Post Helpful? 0
  • +
  • -

#24 FEAST  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 43
  • Joined: 10-April 12

Re: Help building basic println/string out program.

Posted 10 April 2012 - 10:59 PM

Thanks brohan.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2