I have the following problem:
I have a java project that uses gradle. The project structure is:
src
- main
-- java
-- resources
- test
-- java
-- resources
I have the following test class:
package it.main.tests;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class MainTest {
#Test
public void mainTests() {
String s = "ciao";
assertEquals(s, "ciao");
}
}
If I run the following command: gradle test everything is ok. If I try to run the mainTests method from eclipse (right click on the method, Run As, JUnit test) I have the following exception:
Class not found it.main.tests.MainTest
java.lang.ClassNotFoundException: it.main.tests.MainTest
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:770)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:499)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:522)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
This is the build.gradle file:
apply plugin: 'java'
apply plugin: 'war'
sourceCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
}
compileJava {
options.fork = true
}
dependencies {
// Add all the jar dependencies from the lib folder.
compile fileTree(dir: 'src/main/webapp/WEB-INF/lib', include: ['*.jar'])
compile fileTree(dir: '//opt/jenkins/wcs_artifacts/WCS_trunk', include: ['beanstyler.jar', 'UnycoIntegrationBean.jar', 'UnycoModels.jar'])
compile group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1'
compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.11'
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: "5.2.0"
testCompile group: 'org.junit.platform', name: 'junit-platform-launcher', version: "1.2.0"
}
task createWCSAdminWar(type: War, dependsOn: [test, classes]) {
baseName = 'WCSAdmin'
destinationDir = file("$buildDir/dist")
}
task createUnycoAdminWar(type: War, dependsOn: [test, classes]) {
baseName = 'UnycoAdmin'
destinationDir = file("$buildDir/dist")
}
task createDists(dependsOn: [createWCSAdminWar, createUnycoAdminWar])
defaultTasks 'build'
And this is the .classpath file
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/UnycoIntegrationMessages"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/UnycoModels"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="src" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>
Inside webapp/WEB-INF/lib/ I have the junit-4.12.jar file
Can anyone help me? Thanks
Related
I have a pure e4 application and would like it to work in Java 11.
I have a plugin that provides the libraries for our product to use. I've added the latest JAXB libraries to the MANIFEST.MF and .classpathof the plugin.
Plugin MANIFEST.MF
Bundle-ClassPath:
...
jakarta.activation-api-1.2.1.jar,
jakarta.xml.bind-api-2.3.2.jar,
jaxb-osgi-2.3.2.jar,
...
Export-Package:
...
com.sun.xml.bind,
com.sun.xml.bind.v2,
...
Plugin .classpath
...
<classpathentry exported="true" kind="lib" path="jakarta.activation-api-1.2.1.jar"/>
<classpathentry exported="true" kind="lib" path="jakarta.xml.bind-api-2.3.2.jar"/>
<classpathentry exported="true" kind="lib" path="jaxb-osgi-2.3.2.jar"/>
...
Product MANIFEST.MF
Bundle-ClassPath:
...
NameOfPlugin;bundle-version="1.0.0",
...
Import-Package:
...
com.sun.xml.bind.v2,
...
Product .classpath
...
<classpathentry exported="true" kind="lib" path="jakarta.activation-api-1.2.1.jar"/>
<classpathentry exported="true" kind="lib" path="jakarta.xml.bind-api-2.3.2.jar"/>
<classpathentry exported="true" kind="lib" path="jaxb-osgi-2.3.2.jar"/>
...
Run Configuration
I've updated the JVM options for the application.
-Djavax.xml.bind.JAXBContextFactory=com.sun.xml.bind.v2.ContextFactory
Exception
java.util.concurrent.ExecutionException: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory]
at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:552)
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:513)
at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:90)
at com.google.common.util.concurrent.Uninterruptibles.getUninterruptibly(Uninterruptibles.java:199)
at com.google.common.cache.LocalCache$Segment.getAndRecordStats(LocalCache.java:2312)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2278)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2154)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2044)
at com.google.common.cache.LocalCache.get(LocalCache.java:3952)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3974)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4958)
at com.ci.data.reports.ReportFileManager.getAllQueryFromFile(ReportFileManager.java:81)
at com.ci.data.reports.ReportFileManager.lambda$getAllQueryFromFiles$11(ReportFileManager.java:321)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ReduceOps$ReduceTask.doLeaf(ReduceOps.java:952)
at java.base/java.util.stream.ReduceOps$ReduceTask.doLeaf(ReduceOps.java:926)
at java.base/java.util.stream.AbstractTask.compute(AbstractTask.java:327)
at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:746)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Why is it unable to find the ContextFactory class?
From the JARs you have listed, I think you have included only the JAXB APIs but not a JAXB implementation.
Remember that Java 11 broke backwards compatibility by removing JAXB entirely. You need to check whether any of the JARs on your classpath actually contain the class com.sun.xml.bind.v2.ContextFactory.
You probably need something like the org.glassfish.jaxb:jaxb-runtime JAR.
I have my gradle build script set to resolve a TeraData dependency that I have installed to my local maven repository (this dependency is not available on Maven Central). The problem is that the eclipse plugin fails to resolve these dependencies when generating the .classpath file when I execute gradle eclipse.
This is the generated .classpath, with the problematic classpath entries:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry sourcepath="D:/Users/Me/.gradle/this/one/is/good.jar" kind="lib" path="D:/Users/Me/.gradle/caches/modules-2/files-2.1/this/one/is/good.jar"/>
<classpathentry kind="lib" path="D:/dev/workspaces/myworkspace/myproject/unresolved dependency - com.teradata.jdbc terajdbc4 15.10.00.09"/>
<classpathentry kind="lib" path="D:/dev/workspaces/myworkspace/myproject/unresolved dependency - com.teradata.jdbc tdgssconfig 15.10.00.09"/>
</classpath>
This is my gradle.build script, largely copied directly from artifactory's recommended settings:
buildscript {
repositories {
maven {
url 'https://dev.mycompany.com/artifactory/plugins-release'
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
mavenLocal()
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.0.3"
}
}
allprojects {
apply plugin: "com.jfrog.artifactory"
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
}
artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = 'libs-release-local'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
}
resolve {
repository {
repoKey = 'libs-release'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
}
}
dependencies {
/** Note: teradata must be manually installed to local maven repo. **/
compile 'com.teradata.jdbc:terajdbc4:15.10.00.09'
compile 'com.teradata.jdbc:tdgssconfig:15.10.00.09'
}
What is causing the TeraData dependencies to not be resolved? How can I fix it?
You're resolving buildscript dependencies from mavenLocal, but not your project dependencies. Try adding this after the buildscript block:
repositories {
mavenLocal()
}
This is my first time using Java Web Start. This is for a demo version of my application. I have uploaded the JAR to my server, and created a JNLP file. When I run the file locally, I get the exception shown below.
This was the reference I was reading, and below is my JNLP file.
DerbyPro.jnlp
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="" href="">
<information>
<title>Derby Pro</title>
<vendor>Neon Orb</vendor>
<icon href="http://neonorb.com/images/derby-pro/derby-pro-icon-hd.png"/>
<offline-allowed/>
</information>
<resources>
<j2se version="1.8+" href=
"http://neonorb.com"/>
<jar href="http://neonorb.com/clientportal/derby-pro-demo.jar"
main="true" />
</resources>
<application-desc
name="Derby Pro"
main-class="com.neonorb.derbypro.main.DerbyPro"
width="300"
height="300">
</application-desc>
<update check="background"/>
</jnlp>
Here is my build.gradle file being called like this: ./gradlew -Pversion=0.0.0 -Pdemo=true fatJar
group 'com.neonorb'
apply plugin: 'java'
sourceCompatibility = 1.8
project.description = 'Derby Pro is pinewood derby management software.'
//create a single Jar with all dependencies
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Version': version,
'Main-Class': 'com.neonorb.derbypro.main.DerbyPro',
'Demo': demo
}
baseName = project.name
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
repositories {
mavenCentral()
maven {
url "http://www.sparetimelabs.com/maven2"
}
mavenLocal()
}
dependencies {
compile files('dfalex-0.9.2.jar')
compile 'com.neonorb:commons:+'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.5.4'
compile group: 'commons-cli', name: 'commons-cli', version: '1.3.1'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.4'
compile group: 'org.controlsfx', name: 'controlsfx', version: '8.40.10'
compile group: 'org.fxmisc.easybind', name: 'easybind', version: '1.0.3'
compile group: 'org.scream3r', name: 'jssc', version: '2.8.0'
compile group: 'com.sparetimelabs', name: 'purejavacomm', version: '0.0.28'
compile 'net.java.dev.jna:jna:4.2.1'
compile 'commons-io:commons-io:2.4'
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile 'net.jodah:concurrentunit:0.4.2'
}
//Native launchers
//Windows
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'gradle.plugin.edu.sc.seis.gradle:launch4j:1.6.1'
}
}
apply plugin: 'edu.sc.seis.launch4j'
launch4j {
//outputDir = 'native/windows'
bundledJrePath = 'jre'
dontWrapJar = true
jar = 'bin/derby-pro.jar'
mainClassName = 'com.neonorb.derbypro.main.DerbyPro'
icon = '../../src/main/resources/com/neonorb/derbypro/assets/derby-pro-icon-favicon.ico'
outfile = 'DerbyPro.exe'
companyName = 'Neon Orb'
productName = 'Derby Pro'
}
//OS X
/*plugins {
id "edu.sc.seis.macAppBundle" version "2.1.0"
}
macAppBundle {
mainClassName = "com.example.myApp.Start"
icon = "myIcon.icns"
bundleJRE = true
javaProperties.put("apple.laf.useScreenMenuBar", "true")
backgroundImage = "doc/macbackground.png"
}*/
Here is the manifest directory.
And here is the manifest content.
Manifest-Version: 1.0
Implementation-Version: 0.0.0
Main-Class: com.neonorb.derbypro.main.DerbyPro
Demo: true
Your jar file contains duplicate entries which probably cause problems when being deployed. If you run the following command with your jar file you will see the duplicate entries:
$ unzip -l derby-pro-demo.jar |grep META
0 01-26-16 11:47 META-INF/
116 01-26-16 11:47 META-INF/MANIFEST.MF
321 06-09-15 18:42 META-INF/LICENSE
825 06-09-15 18:42 META-INF/NOTICE
...
11358 06-14-15 12:06 META-INF/LICENSE.txt
172 06-14-15 12:06 META-INF/NOTICE.txt
...
11358 04-03-15 14:30 META-INF/LICENSE.txt
301 04-03-15 14:30 META-INF/NOTICE.txt
The problem is caused by the fatJar. See here and here.
When creating a fat jar, the duplicate entries should be resolved. I have no experience with gradle. The issue (first link) is still marked "open", so I assume there may not be an easy fix. As a work around (if this is possible and works for you), I could imagine to copy all jar content first to a temporary directory. This would overwrite duplicate entries. Then you could build the fat jar from the temporary directory. However, I'd be very careful with that. First some duplicate class files may be relevant, and second the LICENSE, NOTICE, etc. files certainly will cause a license problem.
The JNLP file contains a main class attribute, Java Web Start is trying to create the manifest with that main class. Therefore removing the main class attribute from the JNLP file allows it to run.
Hi I am currently using Eclipse Kepler for my java project.
I wanted to use the Octave (the open sourced MatLab) for calculation. Therefore I have tried to use the javaoctave (https://kenai.com/projects/javaoctave) to help me do the calculation in java. However, when I want to compile my code I get the following error:
Exception in thread "main" dk.ange.octave.exception.OctaveIOException: java.io.IOException: Cannot run program "octave": error=2, No such file or directory
at dk.ange.octave.exec.OctaveExec.<init>(OctaveExec.java:102)
at dk.ange.octave.OctaveEngine.<init>(OctaveEngine.java:65)
at dk.ange.octave.OctaveEngineFactory.getScriptEngine(OctaveEngineFactory.java:49)
at learn.CapabilityLearner.connectOctave(CapabilityLearner.java:72)
at learn.CapabilityLearner.connect(CapabilityLearner.java:37)
at learn.CapabilityLearner.<init>(CapabilityLearner.java:24)
at learn.capability.CapabilityMeanVarianceEquation.<init>(CapabilityMeanVarianceEquation.java:10)
at parse.basketball.runner.GetPlayerFrequency.learnSynergyGraph(GetPlayerFrequency.java:102)
at parse.basketball.runner.GetPlayerFrequency.main(GetPlayerFrequency.java:94)
Caused by: java.io.IOException: Cannot run program "octave": error=2, No such file or directory
at java.lang.ProcessBuilder.processException(ProcessBuilder.java:478)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:457)
at java.lang.Runtime.exec(Runtime.java:593)
at dk.ange.octave.exec.OctaveExec.<init>(OctaveExec.java:100)
... 8 more
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:53)
at java.lang.ProcessImpl.start(ProcessImpl.java:91)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
... 10 more
This java project has been successfully run on a Windows machine with Eclipse Kepler so I think it is not the code I have that contains an error. the wiki has mentioned the error and some explanation is given. However, due to my lack of experience with programming I could not have grasped the meaning of the solutions. Can anyone help me to identify the problem and teach me how I shall fix this?
With many thanks ! :)
PS : the .classpath of the project is as followed:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="matlabcontrol-4.0.0.jar"/>
<classpathentry kind="lib" path="javaoctave-0.6.4.jar" sourcepath="javaoctave-0.6.4.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="commons-math-2.2.jar"/>
<classpathentry kind="lib" path="commons-logging-1.1.3.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
You can easily solve your problem setting up the Factory
OctaveEngineFactory factory = new OctaveEngineFactory();
factory.setOctaveProgram(new File("path_to_octave_executable"));
OctaveEngine octave = factory.getScriptEngine();
bgcode
I created a project in Eclipse and executed it succesfuly (It's a normal project, without Maven or Beans, really simple), I created a .jar with the project and tried to execute it but it throws the following error:
C:\Documents\wrapper-windows-x86-64-3.5.19-st\bin>java -cp QuoteHandler.jar stoc
k.view.Main
Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/hiber
nate/cfg/Configuration
Exception in thread "Quotes" java.lang.ExceptionInInitializerError
at stock.controller.HollidayController.<clinit>(HollidayController.java:
25)
at stock.view.MainThread.run(MainThread.java:57)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
at stock.controller.HollidayController.<clinit>(HollidayController.java:
22)
... 2 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more
The .classpath file of the project has:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7"/>
<classpathentry kind="lib" path="lib/antlr-2.7.7.jar"/>
<classpathentry kind="lib" path="lib/dom4j-1.6.1.jar"/>
<classpathentry kind="lib" path="lib/hibernate-commons-annotations-4.0.1.Final.jar"/>
<classpathentry kind="lib" path="lib/hibernate-core-4.1.10.Final.jar" sourcepath="lib/hibernate-core-4.1.10.Final.jar"/>
<classpathentry kind="lib" path="lib/hibernate-entitymanager-4.1.10.Final.jar"/>
<classpathentry kind="lib" path="lib/hibernate-jpa-2.0-api-1.0.1.Final.jar"/>
<classpathentry kind="lib" path="lib/javassist-3.15.0-GA.jar"/>
<classpathentry kind="lib" path="lib/jboss-logging-3.1.0.GA.jar"/>
<classpathentry kind="lib" path="lib/jboss-transaction-api_1.1_spec-1.0.0.Final.jar"/>
<classpathentry kind="lib" path="lib/mysql-connector-java-5.1.20-bin.jar"/>
<classpathentry kind="lib" path="lib/org.springframework.beans_3.1.4.RELEASE.jar"/>
<classpathentry kind="lib" path="lib/org.springframework.web_3.1.4.RELEASE.jar"/>
<classpathentry kind="lib" path="lib/org.springframework.context_3.1.4.RELEASE.jar"/>
<classpathentry kind="lib" path="lib/joda-time-2.2.jar"/>
<classpathentry kind="lib" path="lib/c3p0-0.9.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Checking on the Internet I modify the %CLASSPATH% variable to:
CLASSPATH = C:\Program Files\Java\jre7\lib;C:\Program Files\Java\jre7\lib\c3p0-0.9.1.jar
All the References are well configured in the Build Path of the project and it works, but when I'm executing the .jar it doesn't work (All the references are included in the jar). What am I missing?
when you specifically specify the class path when you run your program with -cp you override the default CLASSPATH os variable.
So you need to either specify all the needed classes/jars as a list in -cp, or you need to modify your CLASSPATH to have the directory of your jar. This question, Setting multiple jars in java classpath, describes setting multiple classpath elements.
Try following option from Eclipse:
File->Export
From the Wizard select Java->Runnable JAR file
Click Next
Select Launch Configuration: Select the class with main() method, if it is not available here then try to run your program once in eclipse
Export Destination: Select full path for your jar file
Library Handling: Select third one "Copy required lib..."
click on finish
Go to command prompt and change the dir to exported jar file and type
java -jar <exported_jar>.jar
One note:
In java for classpath lib/* does not resolve to all jars in directory, you have to type each and every jar entry manually.
You are trying to launch the program using command-line, the .classpath is file is for the eclipse project to maintain the list of jars pertaining to that project and has nothing to do with running the same code from command line, that's why you get the "java.lang.ClassNotFoundException"
Looking at the .classpath file, I think you project structure is like:
Proj
|
|---src
|
|---lib
So in order to run the code you can do,
For windows:
java -cp lib/*;/path/to/your/jar/QuoteHandler.jar stock.view.Main
For UNIX:
java -cp lib/*:/path/to/your/jar/QuoteHandler.jar stock.view.Main
Few things to note here:
-cp argument is ignored if the -jar option is used.
1. So you have two options, modify the manifest file to include the classpath variables
2. Add this jar too in classpath along with other jars as mentioned above, and run the main class.
Also, using -cp will basically override the values of Environment Variable for that session.
Next time again if you try the program again without -cp switch, default value (set in environment variable) of CLASSPATH will be picked.
UPDATE
If you are using this command:
java -cp lib/*;QuoteHandler.jar stock.view.Main
1. Remove quotes they add no value
2. If I look at the command above it means that, you layout is something like:
somefolder
|
|----QuoteHandler.jar
|
|----lib
| |
| |--- antlr-2.7.7.jar
| |--- dom4j-1.6.1.jar
| |--- hibernate-commons-annotations-4.0.1.Final.jar
| |--- hibernate-core-4.1.10.Final.jar
| |---...and so on (NO SUBDIRECTORIES)
Is it the same structure you are having here?
You mentioned in comments of using wildcards.The wildcards only work on JDK 6 onward . So if you JDK version is lesser than that, it might not work (and the way around it to add all the jars in path).