0

I don t know how to run a code into a cmd because it handels a window can you help me?

the code isn t have any bug is the cmd that can t handled it and i don t know if is not supported by my compiling javac xxxx.java

22nd Feb 2017, 10:01 PM
Ismael Perbech
Ismael Perbech - avatar
7 Answers
+ 7
Did you set the path variable in your system environment after installing jdk? https://docs.oracle.com/javase/tutorial/essential/environment/paths.html
22nd Feb 2017, 10:03 PM
Tashi N
Tashi N - avatar
+ 1
This is the code package Juego; import java.awt.BorderLayout; import java.awt.Canvas; import java.awt.Dimension; import javax.swing.JFrame; public class Juego extends Canvas{ private static final long serialVersionUID = 1L; private static final int ANCHO = 800; private static final int ALTO = 600; private static final String NOMBRE = "Juego"; private static JFrame ventana; private Juego(){ setPreferredSize(new Dimension(ANCHO, ALTO)); ventana = new JFrame(NOMBRE); ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ventana.setResizable(false); ventana.setLayout(new BorderLayout()); ventana.add(this, BorderLayout.CENTER); ventana.pack(); ventana.setLocationRelativeTo(null); ventana.setVisible(true); } public static void main(String[] args){ Juego juego = new Juego(); } }
23rd Feb 2017, 3:09 PM
Ismael Perbech
Ismael Perbech - avatar
0
yes and the function javac works
22nd Feb 2017, 10:04 PM
Ismael Perbech
Ismael Perbech - avatar
0
yes i compiled everything
23rd Feb 2017, 2:57 PM
Ismael Perbech
Ismael Perbech - avatar
0
and executed but didn t work
23rd Feb 2017, 2:58 PM
Ismael Perbech
Ismael Perbech - avatar
0
1-you have just to run the cmd window (Windows+R(cmd)) 2-type : dir and click enter if your program or file java in the desktop, you should type : cd desktop then click enter 3- type javac yourfilename.java and click enter 4- type java yourfilename (without .java) and click enter you will see your println
25th Feb 2017, 10:19 PM
ISLMIOUN ahmed
ISLMIOUN ahmed - avatar