Hi everybody! But there is a problem...
Hi!
I am using NetBeans IDE 7.2 and trying to find out why my java-GUI application doesn't work when double clicked but works normaly when I start it from NetBeans :confused: .
When I start my GUI app with doble clicking it, looks like started but no windows seen.
However it's working well when program started in NetBeans...
Thanks in advance!..
{Sorry for my mistakes}
[JAVA]~o)[/JAVA]
Re: Hi everybody! But there is a problem...
Perhaps you have resources such as images or files that are not available in your jar file. It's hard to say without code.
Re: Hi everybody! But there is a problem...
I have a realy simple java-gui application with no resource file or something. The problem is when I try to open my application with my ways, almost nothing happens - except mouse changement - but my app starts normaly when opened with NetBeans (pressing the Run button or F6)
Shortly; opens normal with NetBeans, nothing happens with command line or double-click.
Thanks in advance!..
{Sorry for my mistakes}
Re: Hi everybody! But there is a problem...
How are you trying to execute the program?
1 Attachment(s)
Re: Hi everybody! But there is a problem...
Attachment 1404
I'm just clicking on it but no windows or something appears :confused:
Re: Hi everybody! But there is a problem...
You either have an error or you're target program to open the file isn't linking to the Java in the JRE directory.
Open command prompt in the directory of your file, and enter java -jar JavaApplication2.jar.
If it opens with no error messages, it's because you haven't set the right target for .jars, but if you have errors, paste them in here.
Re: Hi everybody! But there is a problem...
On windows: To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Paste here.
Re: Hi everybody! But there is a problem...
Error: Could not find or load main class javaapplication2.JavaApplication2
I tried to do the same thing in javaFX and it has no problem at all. I copied codes to a javaFX project and it works fine when double clicked.
Re: Hi everybody! But there is a problem...
Look in the jar file with a zip utility:
1)Read the manifest file. What is in it?
2)Is there a class file named: JavaApplication2 in the javaapplication2 folder?
Re: Hi everybody! But there is a problem...
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.3
Created-By: 1.7.0_07-b10 (Oracle Corporation)
Class-Path:
X-COMMENT: Main-Class will be added automatically by build
Main-Class: javaapplication2.JavaApplication2
There is 2 class files which named NewJFrame and NewJFrame$1 . But I was already selected the main class in NetBeans.
Maybe its the problem...
Re: Hi everybody! But there is a problem...
Re: Hi everybody! But there is a problem...
This line tells the java program where to start:
Main-Class: javaapplication2.JavaApplication2
it's going to look for that class file in the jar file.
If that class file is NOT in the jar file, you get the error:
Could not find or load main class javaapplication2.JavaApplication2
You need to find out how to use the IDE to build a jar file. There is a section of the forum for problems with IDEs.