Code:package practice;
public class variables1 {
public static void main(String[] args){
System.out.print("Hello");
}
}
Printable View
Code:package practice;
public class variables1 {
public static void main(String[] args){
System.out.print("Hello");
}
}
What problems are you having? Does the manifest file identify this class as the one with the application's entry point, the Main-Class?
Umm.. i'm not exactly sure, but it works in eclipse and shows the text "Hello" in the console like it should, but when i export it to the desktop, the file doesnt run when i click it
When you click it you will never see if it runs since you don't create a long-standing console window. If you're in Windows, create a console via cmd.exe, and run your jar file from there.
Ok, and how exactly can i do that?
Sorry for not knowing this.. :/
do what? Run a jar file on the command line? Google can help you find that. One of the first hits it gave me was: Running JAR-Packaged Software (The Java™ Tutorials > Deployment > Packaging Programs in JAR Files)
I looked at that page but didn't really understand much of it.
I dont know what type of file this would be, but I CAN tell you what i want to do.
Here's what i want to do:
I made a new project and made a new class in that.
I wrote this code into that class:
It runs and shows the message "Hello" on the console in Eclipse.Code:package practice;
public class variables1 {
public static void main(String[] args){
System.out.print("Hello");
}
}
Here's where I don't know what to do:
I don't know how to make that file into some file in a folder that can be clicked on, and open a window that shows the message "Hello" and closes when i click X.
That's what i want to do.
Thanks alot
The simplest solution is to display your output with a JOptionPane:
Then use Eclipse's export wizard to create a jar file that holds this file, but making sure to set the Main class in the export wizard to this class.Code:import javax.swing.JOptionPane;
public class HelloWorld {
public static void main(String[] args) {
JOptionPane.showMessageDialog(null, "Hello World");
}
}
Then if your OS has been configured correctly, double clicking on the jar file will run the class and show the option pane.
Thank you very much!
Not only did you help me out, but you gave me a valuable tip(the dialogue box thing).
You're welcome!