snajalm
asked on
Setting up Embedded Java DB System Directory?
My application runs perfectly under Netbeans but when I build it and launch the jar file it comes up with Java Virtual Machine Launcher "A Java Exception has occured" pop-up. I ran the java -myjar.jar and it just says a fatal error has occured. I presume that it can't create my database at main and that's why it's coming up with this error. I have implemented the Embedded Java DB system and and in order to set the database to be created, I have performed the following routine of code,
Do you think this is right or I'm missing something??!
String userHomeDir = System.getProperty("user.home");
String systemDir = userHomeDir + "\\LMB\\";
// Set the db system directory.
System.setProperty("derby.system.home", systemDir);
conn = DriverManager.getConnection("jdbc:derby:LMB; create=true;");
Do you think this is right or I'm missing something??!
What is the stacktrace of your exception - please post the details
Do you have set your, classpath so external properties/libraries could be found?
Could you post the error message that is displayed in your console?
Could you post the error message that is displayed in your console?
A Java Exception has occured - that can easily be about anything - before you make conculusion you should
look at the details of exception
ASKER
I run
And it only shows this error.
I'm sure there is main method in my application class. I don't understand what this is supposed to mean!
java myfile.jar
And it only shows this error.
Error: Could not find or load main class myfile.jar
I'm sure there is main method in my application class. I don't understand what this is supposed to mean!
Your jar poerhaps is not executable jar
jar -jar myfile.jar
-jar is necessary
-jar is necessary
even if jar is executable you need -jar to run it from jar
java -jar myfile.jar
try this and let us know
java -jar myfile.jar
try this and let us know
ASKER
C:\Documents and Settings\User\Desktop>java -jar myfile.jar
Exception in thread "main" java.lang.NoClassDefFoundE rror: org/jdesktop/applicat
ion/SingleFrameApplication
at java.lang.ClassLoader.defi neClass1(N ative Method)
at java.lang.ClassLoader.defi neClass(Un known Source)
at java.security.SecureClassL oader.defi neClass(Un known Source)
at java.net.URLClassLoader.de fineClass( Unknown Source)
at java.net.URLClassLoader.ac cess$100(U nknown Source)
at java.net.URLClassLoader$1. run(Unknow n Source)
at java.net.URLClassLoader$1. run(Unknow n Source)
at java.security.AccessContro ller.doPri vileged(Na tive Method)
at java.net.URLClassLoader.fi ndClass(Un known Source)
at java.lang.ClassLoader.load Class(Unkn own Source)
at sun.misc.Launcher$AppClass Loader.loa dClass(Unk nown Source)
at java.lang.ClassLoader.load Class(Unkn own Source)
at sun.launcher.LauncherHelpe r.checkAnd LoadMain(U nknown Source)
Caused by: java.lang.ClassNotFoundExc eption: org.jdesktop.application.S ingleFram
eApplication
at java.net.URLClassLoader$1. run(Unknow n Source)
at java.net.URLClassLoader$1. run(Unknow n Source)
at java.security.AccessContro ller.doPri vileged(Na tive Method)
at java.net.URLClassLoader.fi ndClass(Un known Source)
at java.lang.ClassLoader.load Class(Unkn own Source)
at sun.misc.Launcher$AppClass Loader.loa dClass(Unk nown Source)
at java.lang.ClassLoader.load Class(Unkn own Source)
... 13 more
Exception in thread "main" java.lang.NoClassDefFoundE
ion/SingleFrameApplication
at java.lang.ClassLoader.defi
at java.lang.ClassLoader.defi
at java.security.SecureClassL
at java.net.URLClassLoader.de
at java.net.URLClassLoader.ac
at java.net.URLClassLoader$1.
at java.net.URLClassLoader$1.
at java.security.AccessContro
at java.net.URLClassLoader.fi
at java.lang.ClassLoader.load
at sun.misc.Launcher$AppClass
at java.lang.ClassLoader.load
at sun.launcher.LauncherHelpe
Caused by: java.lang.ClassNotFoundExc
eApplication
at java.net.URLClassLoader$1.
at java.net.URLClassLoader$1.
at java.security.AccessContro
at java.net.URLClassLoader.fi
at java.lang.ClassLoader.load
at sun.misc.Launcher$AppClass
at java.lang.ClassLoader.load
... 13 more
You need to have this stuff from netbeans in the classpath or on the jar
Your application is using the Swing Application Framework. You need to include its jar in your classpath. AppFramework-1.02.jar should be in your classpath.
maybe versions is now different
appframework-1.0.3.jar is missing on the classpath
you can download it form here even though you probably have it somewhere in youtr netbeans, but it may be easier to download
http://mirrors.ibiblio.org/pub/mirrors/maven2/net/java/dev/appframework/appframework/1.03/appframework-1.03.jar
I think you still can do it like this :
jar -cp appframework-1.03.jar -jar myfile.jar
I hope with -jar
-cp still should be working
ASKER
But they're all there in Netbeans as can be seen in the image provided!
untitled.bmp
untitled.bmp
Correct but when your making a jar other jars are not bundled into the created jar, so you have to put the libraries on the classpath yourseld
but you are not executing it inside netbeans , you are executing it on command line - so it probably
was not packaged to jar for some reason
was not packaged to jar for some reason
I don't know how you intend to package your app but you should be able to execute with Ant without problem. Ant is already in Netbeans but you should, as a developer, install it separately too, so you have the user binaries. After setting ANT_HOME and adding %ANT_HOME%\bin to your path, you should find that the following runs your project with error
ant -f <path to build.xml of your project> run
ASKER
Sorry CEHJ, I didn't see this last message! But what is an "ant" and where should I get it??!
Ant is the primary build tool for Java.
http://ant.apache.org/bindownload.cgi
Should definitely be installed for you imo
http://ant.apache.org/bindownload.cgi
Should definitely be installed for you imo
ASKER
I installed and ran the command you proposed and everything runs smoothly outside the Netbeans environment! However I can't find the jar fine anywhere! What should I do from there???!
The application jar? You'll find it's at
<project name>\dist\<project name>.jar
<project name>\dist\<project name>.jar
ASKER
I can't find it. I noticed that it seems that it runs the application but doesn't build a jar file. Is there any other command that would create a jar file??!
Try the following then look again
ant -f <path to build.xml in your project> jar
ASKER
BUILD FAILED
C:\Documents and Settings\User\My Documents\NetBeansProjects \iDA\iDA\n bproject\b
uild-impl.xml:944: The following error occurred while executing this line:
C:\Documents and Settings\User\My Documents\NetBeansProjects \iDA\iDA\n bproject\b
uild-impl.xml:366: The <classpath> for <junit> must include junit.jar if not in
Ant's own classpath
Total time: 1 second
C:\Documents and Settings\User\My Documents\NetBeansProjects
uild-impl.xml:944: The following error occurred while executing this line:
C:\Documents and Settings\User\My Documents\NetBeansProjects
uild-impl.xml:366: The <classpath> for <junit> must include junit.jar if not in
Ant's own classpath
Total time: 1 second
ASKER
When I ran the application with your initial command which included the run, my application behaved as it should have but after it's built with you latest command. It builds successfully but does not behave the way it supposed to. How could this possibly be???! I'm lost here...
http:#37000315 is the result of running the very last comment i posted?
ASKER
No, "ant -f <path to build.xml in your project> jar" runs successfully but runs with some problems whereas this same project while using the "ant -f <path to build.xml in your project> run" performs just the way it does withing Netbeans (which is the way it supposed to be). It seems that this project has some problems with being built!
ant -f <path to build.xml in your project> without the jar and the end comes up with the Error message I showed you!
ant -f <path to build.xml in your project> without the jar and the end comes up with the Error message I showed you!
ASKER
Any ideas or suggestions???!!!
What does the following give at the command line?
echo %ANT_HOME%
ASKER
%ANT_HOME%
ASKER
Sorry, I did what you said and running echo %JAVA_HOME% I get
C:\Program Files\Java\jdk1.7.0
But now that I'm trying to run ant -f buil.xml jar, it comes up with the following message,
'ant' is not recognied and an internal or external command, operable program or bacth file.
What have I done wrong here now??!
C:\Program Files\Java\jdk1.7.0
But now that I'm trying to run ant -f buil.xml jar, it comes up with the following message,
'ant' is not recognied and an internal or external command, operable program or bacth file.
What have I done wrong here now??!
ASKER
let me tell you what I have in my environment variable list,
ANT_HOME = C:\Program Files\apache-ant-1.8.2
CLASSPATH=.;C:\Program Files\Java\jre6\lib\ext\QT Java.zip
PATH=C:\Program Files\PC Connectivity Solution\;%SystemRoot%\sys tem32;%Sys temRoot%;% SystemRoot %\System32 \Wbem;C:\P rogram Files\Common Files\DivX Shared\;C:\Program Files\Common Files\Ulead Systems\MPEG;C:\Program Files\QuickTime\QTSystem\; c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\ Program Files\Microsoft SQL Server\100\DTS\Binn\;%ANT_ HOME%\bin
Is there anything wrong here you think??!
ANT_HOME = C:\Program Files\apache-ant-1.8.2
CLASSPATH=.;C:\Program Files\Java\jre6\lib\ext\QT
PATH=C:\Program Files\PC Connectivity Solution\;%SystemRoot%\sys
Is there anything wrong here you think??!
If http:#37000738 is what you get when you run the command i mentioned, either
a. setting the variables didn't work
b. you haven't opened a NEW command window since you set them
With any luck, b. will be the case
a. setting the variables didn't work
b. you haven't opened a NEW command window since you set them
With any luck, b. will be the case
ASKER
Ok I fixed it now! echo %JAVA_HOME% is pointing to the right direction and ant is launching throughout the system. Again I have this issue of a successful build but awkward application behaviour. The application still runs flawlessly under Netbeans itself and by using the command "ant -f build.xml run". Can you tell me anything that could give me a logic behind where I went wrong??! I know that I'm disturbing you but I would really appreciate it if you keep helping me out with this issue!
>> echo %JAVA_HOME%
Glad that's working but it's not really relevant here
Please post full current error(s)
Glad that's working but it's not really relevant here
Please post full current error(s)
ASKER
How can I capture errors while launching the jar file from explorer??! When I run "ant -f buid.xml run" I don't get any errors! Is there a command that would log the errors made my running a jar file??!
You can't run it like that - no wonder you're getting errors!
ASKER
Then how should I run it then??! Shouldn't the jar file be able to run through the explorer??!
A single jar has to have all its dependencies met. Other jars should be included in the manifests's classpath. Or use a 'fat jar' approach
ASKER
PLEASE let me know how these techniques work?? How can I set up a manifest file?! Isn't the manifest file generated automatically by ant or Netbeans??! When I unzip the jar file, I can see that there is already a META-INF folder where the manifest file MANIFEST.MF exist. I don't know this file is set up right though but please let me know how I should do it manually if I have to.
ASKER
This is a copy of the manifest file embedded in my jar file. It seem to have pointed to all the libraries as I check against the Netbeans listing! Do you think this should be arranged differently??!
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.2
Created-By: 1.7.0-b147 (Oracle Corporation)
Class-Path: lib/beansbinding-1.2.1.jar lib/AbsoluteLayout.jar lib/appf
ramework-1.0.3.jar lib/swing-worker-1.1.jar lib/swing-layout-1.0.4.ja
r lib/commons-codec-1.4.jar lib/commons-codec-1.5.jar lib/commons-log
ging-1.1.1.jar lib/derby.jar lib/derbyLocale_cs.jar lib/derbyLocale_d
e_DE.jar lib/derbyLocale_es.jar lib/derbyLocale_fr.jar lib/derbyLocal
e_hu.jar lib/derbyLocale_it.jar lib/derbyLocale_ja_JP.jar lib/derbyLo
cale_ko_KR.jar lib/derbyLocale_pl.jar lib/derbyLocale_pt_BR.jar lib/d
erbyLocale_ru.jar lib/derbyLocale_zh_CN.jar lib/derbyLocale_zh_TW.jar
lib/derbyclient.jar lib/derbynet.jar lib/derbyrun.jar lib/derbytools
.jar lib/httpclient-4.1.2.jar lib/httpclient-cache-4.1.2 .jar lib/http
core-4.1.2.jar lib/httpmime-4.1.2.jar lib/jdom.jar lib/orangevolt-ant
-tasks-1.3.8.jar
X-COMMENT: Main-Class will be added automatically by build
Main-Class: ida.LMBApp
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.2
Created-By: 1.7.0-b147 (Oracle Corporation)
Class-Path: lib/beansbinding-1.2.1.jar
ramework-1.0.3.jar lib/swing-worker-1.1.jar lib/swing-layout-1.0.4.ja
r lib/commons-codec-1.4.jar lib/commons-codec-1.5.jar lib/commons-log
ging-1.1.1.jar lib/derby.jar lib/derbyLocale_cs.jar lib/derbyLocale_d
e_DE.jar lib/derbyLocale_es.jar lib/derbyLocale_fr.jar lib/derbyLocal
e_hu.jar lib/derbyLocale_it.jar lib/derbyLocale_ja_JP.jar lib/derbyLo
cale_ko_KR.jar lib/derbyLocale_pl.jar lib/derbyLocale_pt_BR.jar lib/d
erbyLocale_ru.jar lib/derbyLocale_zh_CN.jar lib/derbyLocale_zh_TW.jar
lib/derbyclient.jar lib/derbynet.jar lib/derbyrun.jar lib/derbytools
.jar lib/httpclient-4.1.2.jar lib/httpclient-cache-4.1.2
core-4.1.2.jar lib/httpmime-4.1.2.jar lib/jdom.jar lib/orangevolt-ant
-tasks-1.3.8.jar
X-COMMENT: Main-Class will be added automatically by build
Main-Class: ida.LMBApp
No - that should be fine - *as long as* java is invoked from the directory containing the app jar. If you want to start it with a Windows shortcut, make sure the working directory in the shortcut properties is the one with the app jar in it
ASKER
NOTE:
Here I FOUND THE SOURCE OF THIS ISSUE BUT I DON'T KNOW HOW TO FIX IT,
Everything about library referencing and environment variables are ok except the fact that I'm not getting my SSL connection to the server while launching the jar file whereas the connection is easily made while running the application from inside Netbeans. In fact I'm getting this following Exception when executing through the final jar fine,
PLEASE HELP ME WITH THIS
Here I FOUND THE SOURCE OF THIS ISSUE BUT I DON'T KNOW HOW TO FIX IT,
Everything about library referencing and environment variables are ok except the fact that I'm not getting my SSL connection to the server while launching the jar file whereas the connection is easily made while running the application from inside Netbeans. In fact I'm getting this following Exception when executing through the final jar fine,
javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated at sun.security.ssl.SSLSessionImpl.getPeerCertificates(Unknown Source)
PLEASE HELP ME WITH THIS
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It ended up that Netbeans didn't want to include the JVM Options in the build.xml file and I had to manually put them in main. Such unpredictable IDE. Anyhow, my deepest appreciation CEHJ for bearing with me in solving this issue!
public static void trustStore() {
Properties systemProps = System.getProperties();
systemProps.put("javax.net .ssl.trust Store", "jssecacerts");
System.setProperties(syste mProps);
}
public static void trustStore() {
Properties systemProps = System.getProperties();
systemProps.put("javax.net
System.setProperties(syste
}
:)