• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jar files not executing/runing under windows8.1

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello guys,

I've just installed the last Java kit JDK plus netbeans and I've done my first project in Java.
It is running perfect from command line<but is is difficult to execute each time from there my tests> but I couldn't run the jar file from windows with double click he jar file even I've spent 3 hour on google to find different methods (registry modifying, control panel/program running in windows, a patch file etc, ) no one of this solutions solved my problem

please help me with a successful advice!

BR
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you added the appropriate Main-Class entry to the JAR file's META-INF/MANIFEST.MF (tutorial)?
 
Nicu Surdu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jelle Klap wrote:Have you added the appropriate Main-Class entry to the JAR file's META-INF/MANIFEST.MF (tutorial)?



well,

this is my script, I'm following some tutorials, I've compiled and in the command line is ok, the message is shown, but when I double clikv on jar nothing is happenig...

thank you!

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package firstprj;

import javax.swing.JOptionPane;


/**
*
* @author baby
*/
public class FirstPrj {



/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here

String nume;


System.out.println( "My First Project" );
System.console();
nume = "System.in";

}

}
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nicu Surdu wrote:
this is my script, I'm following some tutorials, I've compiled and in the command line is ok, the message is shown, but when I double clikv on jar nothing is happenig...



This is a repeat of your question (with some code). Please answer Jelle's question.

Henry
 
Nicu Surdu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:

Nicu Surdu wrote:
this is my script, I'm following some tutorials, I've compiled and in the command line is ok, the message is shown, but when I double clikv on jar nothing is happenig...



This is a repeat of your question (with some code). Please answer Jelle's question.

Henry



this is a problem that I don't know what and how to answer

I've just tried my first program to show something like hello world

the project is executed from cmd exe

but in windows .1 I cand double click on the jar file cause isn't running/executing anything....

and the question and the link from above don't tell me anything ...that's way I've given you my script to see all what i have done in netbeans...


thank you for understanding a novice!
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you double-click on an executable jar file, then you won't have the console window (or it appears and disappears immediately), so you won't see output that you print with System.out.println().

Your program only does one thing: print "My First Project" on the console, and then you have a few other statements in the main method but they don't have any effect. Since there is no console when you double-click the jar, you won't see anything.
 
Nicu Surdu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesper de Jong wrote:When you double-click on an executable jar file, then you won't have the console window (or it appears and disappears immediately), so you won't see output that you print with System.out.println().

Your program only does one thing: print "My First Project" on the console, and then you have a few other statements in the main method but they don't have any effect. Since there is no console when you double-click the jar, you won't see anything.



Yes when I double click nothing is happening, this is correct? (I want to see the message shown somewhere)....
 
Nicu Surdu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nicu Surdu wrote:

Jesper de Jong wrote:When you double-click on an executable jar file, then you won't have the console window (or it appears and disappears immediately), so you won't see output that you print with System.out.println().

Your program only does one thing: print "My First Project" on the console, and then you have a few other statements in the main method but they don't have any effect. Since there is no console when you double-click the jar, you won't see anything.



Yes when I double click nothing is happening, this is correct? (I want to see the message shown somewhere)....



I mean should print the message but I can see anything printed .....( where to see the message??? the console isn't opeded).. I mean I executed the jar file from inside the cmd.exe and there in console the message is printed....

thanks
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nicu Surdu wrote:
I mean should print the message but I can see anything printed .....( where to see the message??? the console isn't opeded).. I mean I executed the jar file from inside the cmd.exe and there in console the message is printed ....



Did you? Can you show us the command line that you used?

There is a difference between running an executable jar file *and* running a java class with a jar file in the classpath.

Henry
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nicu, I tried to explain it to you:

When you double-click an executable jar file, there is no console window, so you will not be able to see the output.

When you run it from the command prompt yourself (cmd.exe) with a command like "java -jar myfile.jar" then the console is available and you will see the message. But not when you do not have a command prompt window open and you double-click the icon of the jar file.

That's just how it works. You're not going to be able to see console output when you double-click the jar to run it.

So, if you want to be able to run your program by double-clicking the jar, then you'll have to do something else instead of using System.out.println(). For example, show a message dialog. I see you already imported javax.swing.JOptionPane in your program, but you're not using it anywhere. Example:
 
Nicu Surdu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesper de Jong wrote:Nicu, I tried to explain it to you:

When you double-click an executable jar file, there is no console window, so you will not be able to see the output.

When you run it from the command prompt yourself (cmd.exe) with a command like "java -jar myfile.jar" then the console is available and you will see the message. But not when you do not have a command prompt window open and you double-click the icon of the jar file.

That's just how it works. You're not going to be able to see console output when you double-click the jar to run it.

So, if you want to be able to run your program by double-clicking the jar, then you'll have to do something else instead of using System.out.println(). For example, show a message dialog. I see you already imported javax.swing.JOptionPane in your program, but you're not using it anywhere. Example:




Well thank you for the great answer, now I think I am on the great line to start a java tutorial(sorry for these blind questions, I have a C, pascal and basic background and now I'm learning .net and java....let see how efficient i will be )...any tutorials or learning materials are very welcome!


 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The best place to start are Oracle's Java Tutorials - there's a whole list of tutorials there, from absolute beginner level to advanced topics.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic