Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 13 of 13

Thread: "null" output in console after runing

  1. #1
    Junior Member
    Join Date
    Jul 2020
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default "null" output in console after runing

    helo,

    i am working on a game and everything has been fine for like four month but now when i run the program i get "null" in the console. it seem like it run sometime and it was crashing my laptop in eclipse. i am using netbean.

    i just started with full scren so i do not realy know if my code is any good.

    it is kinda a big program and need image file so it is a zip folder and can be downloaded from https://www.filehosting.org/file/det...game%20(2).zip

    the main latest class is "wolfruning" then i have a older backup caled "araylistcolision" that might be simpler to read.

    it is just tough because i do not get a stack trace or whatever that say what line is null

    i am al done designing the game if you have gimp you can see the xcf design in the file "lonzeheitaforestdesignquesst" then i have the menu design "menudesign" prety much i gota throw in the credit. i am developing now.

    basicly the game is two part (object oriented programing). number one is the unit clas and number two is the scren clas. their is only going to be thre unit. wooyl, the wolf, and maybe the quest giver. ther is going to be thre scren.

    it only work (prety) in 1366 / 768 resolution i mean it might compile in other but it doe not look good

    if it work (basicaly it look like a busines (it might work)) "heitaforesttwo" version is good you can walk western it is like four minute.

    i remember it hapened to me like four month ago when all i had was my graphic envirnment code on ther i think.

    i want to put it in a jframe, maxamized.

    anyone ever seen this?

    thank you,
    nathaniel
    Last edited by nathaniel victor nelson; February 17th, 2021 at 01:34 AM. Reason: aded more

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    24,380
    Thanks
    54
    Thanked 2,636 Times in 2,586 Posts

    Default Re: "null" output in console after runing

    What statement prints the message with the word null in it? What is the full text of the message?
    Can you open a command prompt window, execute the program, copy the contents of the command prompt window with the "null" message and paste it here?

    i do not get a stack trace
    Does the code have any catch blocks that do not call the printStackTrace method? If so, change all of them to call the printStackTrace method so you get a full stack trace when an exception is thrown.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Jul 2020
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: "null" output in console after runing

    here is a picture of the eror https://www.filehosting.org/file/det...24108/eror.png

    i only throw eror. i wil try try catch and println eror

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    24,380
    Thanks
    54
    Thanked 2,636 Times in 2,586 Posts

    Default Re: "null" output in console after runing

    Please copy the text from the console window and paste it here. No links to images. I do not connect to other sites.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Jul 2020
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: "null" output in console after runing

    people alway tel me i should not use try and i heard java graphic device doe not even work half the time

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    24,380
    Thanks
    54
    Thanked 2,636 Times in 2,586 Posts

    Default Re: "null" output in console after runing

    Sorry, I do not understand what you are saying.
    What statement/message is the word "null" in? Is it from a statement in your program?

    i get "null" in the console
    What console is that? The command prompt, an IDE or what?
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Jul 2020
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: "null" output in console after runing

    i put it in a jframe

    i think it was in my unit clas where the null was. i aded
     unitrectangle = new Rectangle(x.intValue(), y.intValue(), wolfnorthern.getWidth(), wolfnorthern.getHeight());
    to my "if unit = wolf" area in the unit clas and i think it fixed it because that was null

    eclipse did not crash that time and printed the stack trace or whatever said it was the unitrectangle variable at my wolf iterator or whatever

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    24,380
    Thanks
    54
    Thanked 2,636 Times in 2,586 Posts

    Default Re: "null" output in console after runing

    it fixed it
    Good
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Jul 2020
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: "null" output in console after runing

    hmmm now it is saying "null" again. like i said it doe it half the time

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    24,380
    Thanks
    54
    Thanked 2,636 Times in 2,586 Posts

    Default Re: "null" output in console after runing

    Is "null" all you see on the console? What statement puts that value on the console?
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Jul 2020
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: "null" output in console after runing

    i canot even do a
                System.out.println("working");
    at the first line of my main method

    --- Update ---

    here i took all the media file off so it should run in your integrated development envirnment
    /*
     * open source license
     */
     
    package nathangame;
     
     
     
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.Graphics;
    import java.awt.GraphicsDevice;
    import java.awt.GraphicsEnvironment;
    import java.awt.Polygon;
    import java.awt.Rectangle;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.geom.Line2D;
    import java.awt.geom.Rectangle2D;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import java.util.ArrayList;
    import javax.imageio.ImageIO;
    import javax.sound.midi.InvalidMidiDataException;
    import javax.sound.midi.MidiSystem;
    import javax.sound.midi.MidiUnavailableException;
    import javax.sound.midi.Sequence;
    import javax.sound.midi.Sequencer;
    import javax.sound.sampled.AudioFormat;
    import javax.sound.sampled.AudioInputStream;
    import javax.sound.sampled.AudioSystem;
    import javax.sound.sampled.Clip;
    import javax.sound.sampled.DataLine;
    import javax.sound.sampled.LineUnavailableException;
    import javax.sound.sampled.UnsupportedAudioFileException;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.Timer;
    /**
     * video game in progres. alow character movement in a world. right click to move character.
     * @author nathaniel victor nelson
     * @since ~6 / 29 / two thousand twenty
     */
    public class Roleplayinggamenulltest extends JFrame implements MouseListener, KeyListener, ActionListener{
    	// extend jframe to create window (aplication)
    	private static final long serialVersionUID = 1L;
     
    	// define variable here to be used anywhere in clas
     
    	/** mouse pointer location */
    	Double mousex, mousey;
     
    	File file;
    	BufferedImage bufferedimage;
    	Boolean once;
    	Line2D line;
     
     
    	Timer repainttimer;
     
    	/** lonze mid file */
    	Sequence lonze;
     
    	Sequence heitaforest;
     
    	/** indicate wheither the video game menu is showing */
    	Boolean menu;
     
     
    	/** scren size of the user */
    	Dimension screensize;
     
        File yourFile;
        AudioInputStream stream;
        AudioFormat format;
        DataLine.Info info;
        Clip clip;
        Sequencer sequencer;
     
        /** lonze mid file */
        File lonzemid;
     
        /** heita forest mid file */
        File heitaforestmid;
     
        /** wooyl footstep wav sound */
        File footstep;
     
        /** the video game menu object */
        menurectangle menurectangleobject;
     
        /** has boolean like "has just entered heita forest" */
        displaytowninformation displaytowninformationobject;
     
    	public static void main(String[] args) throws IOException, MidiUnavailableException, InvalidMidiDataException, UnsupportedAudioFileException, LineUnavailableException { 
    	    // where program start
                System.out.println("working");
    		GraphicsDevice graphicsdevice;
    		GraphicsEnvironment graphicsenvironment;
    		graphicsenvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    		graphicsdevice = graphicsenvironment.getDefaultScreenDevice();    
    		if (!graphicsdevice.isFullScreenSupported()) {
    		      System.out.println("Full screen mode not supported");
    		      System.exit(1);
    		    }
    			// set aplication to ful scren
    			graphicsdevice.setFullScreenWindow(new Roleplayinggamenulltest());
    	}
     
    	/** roleplayinggame clas main method. is caled when a new roleplayinggame() is caled */
    	public Roleplayinggamenulltest() throws IOException, MidiUnavailableException, InvalidMidiDataException, UnsupportedAudioFileException,
    	LineUnavailableException {
                System.out.println(Toolkit.getDefaultToolkit().getScreenSize());
    		screensize = Toolkit.getDefaultToolkit().getScreenSize();
    		sequencer = MidiSystem.getSequencer();
    		sequencer.open();
    		sequencer.setSequence(lonze);
    		sequencer.setLoopCount(5);
    		sequencer.start();
    		format = stream.getFormat();
    		info = new DataLine.Info(Clip.class, format);
    		clip = (Clip) AudioSystem.getLine(info);
    		clip.open(stream);
    		// ad jpanel to jframe. alow drawing.
    		menu = new Boolean(false);
    		addMouseListener(this);
    		addKeyListener(this);
    		setSize((int)screensize.getWidth(), (int)screensize.getHeight());
                    setResizable(false);
                    setUndecorated(true);
    		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		setVisible(true);
    		menurectangleobject = new menurectangle();
    		//System.out.println(sequencer.getSequence().equals(lonze));
    		displaytowninformationobject = new displaytowninformation();
    		displaytowninformationobject.locationtimer.start();
    		//System.out.println(menurectangleobject.locationtimer.isRunning());
    	}
     
     
     
    	public void setloopandstart() {
    		sequencer.setLoopCount(5);
    		sequencer.start();
    	}
     
    	/** video game menu. */
    	class menurectangle{
    		/** menu background */
    		Rectangle background;
    		public menurectangle() {
    			background = new Rectangle((int)(screensize.getWidth() / 2) - 250, (int)(screensize.getHeight() / 2) - 200, 500, 400);
    		}
    	}
     
    	/** handle town display information */
    	class displaytowninformation implements ActionListener{
    		/** display curent or new town if entered. display for delay set */
    		Timer locationtimer;
    		Boolean displayinglonze, displayingheitaforest;
    		public displaytowninformation() {
    			displayinglonze = new Boolean(true);
    			displayingheitaforest = new Boolean(false);
    			//locationtimer.setInitialDelay(0);
    			locationtimer = new Timer(50000, this);
    		}
    		public void actionPerformed(ActionEvent e) {
    			displayingheitaforest = false;
    			displayinglonze = false;
    			locationtimer.stop();
    		}
    	}
     
    	@Override
    	public void mouseClicked(MouseEvent e) {
     
    	}
     
    	@Override
    	public void mousePressed(MouseEvent e) {
     
    	}
     
    	@Override
    	public void mouseReleased(MouseEvent e) {
    		// caled when mouse buton released
    		if (e.getButton() == 3) {
    			}
    		}
     
    	@Override
    	public void mouseEntered(MouseEvent e) {
     
    	}
     
    	@Override
    	public void mouseExited(MouseEvent e) {
     
    	}
     
    	@Override
    	public void keyTyped(KeyEvent e) {
     
    	}
     
    	@Override
    	public void keyPressed(KeyEvent e) {
     
    	}
     
    	@Override
    	public void keyReleased(KeyEvent e) {
    		if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
    			System.exit(0);
    		}
    		if (e.getKeyCode() == KeyEvent.VK_ENTER) {
    			if (!menu.equals(true)) {
    			menu = true;
    			}
    			else {
    				menu = false;
    			}
    		}
    	}
     
    	@Override
    	public void actionPerformed(ActionEvent e) {
     
    	}
    }


    --- Update ---

    oh shoot my run configuration was off in netbean - let me see if i can get some information

    --- Update ---

    hmmm weird when i clicked run in a new file it was runing my older version which look broken and it doe not show my new file at the set run configuration. i think i got it working in eclipse

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    24,380
    Thanks
    54
    Thanked 2,636 Times in 2,586 Posts

    Default Re: "null" output in console after runing

    I get this error stack (probably different line numbers)
    Exception in thread "main" java.lang.IllegalStateException: sequence not set
    at com.sun.media.sound.RealTimeSequencer.start(Unknow n Source)
    at Roleplayinggamenulltest.<init>(Roleplayinggamenull test.java:134)
    at Roleplayinggamenulltest.main(Roleplayinggamenullte st.java:122)
    If you don't understand my answer, don't ignore it, ask a question.

  13. #13
    Junior Member
    Join Date
    Jul 2020
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: "null" output in console after runing

    hmmm i never got a chance to run that one

    i think what hapend was there was something wrong with my
    int[]
    i switched to ussing an arraylist i think that is what fixed it.

    i alway hear people say
    int[]
    suck and i should use arraylist or maybe even concuenthashmap

Similar Threads

  1. Replies: 4
    Last Post: July 18th, 2014, 02:04 AM
  2. Replies: 1
    Last Post: July 16th, 2014, 04:16 AM
  3. Replies: 2
    Last Post: May 22nd, 2014, 01:17 PM
  4. [SOLVED] will u tell me why i am getting output "null"
    By cnshah9270 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 22nd, 2014, 07:58 AM
  5. [SOLVED] "null" in my output :( Scanner problem?
    By crys in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 2nd, 2012, 09:05 PM