classpath

Run java application from command line with external jar files

℡╲_俬逩灬. 提交于 2019-12-04 05:09:01
I have an external jar file(have package structure), which contains the main class, and I can run the app from command line like this: java -jar example.jar But I still have another test.class file outside this jar file, and some classes inside this jar file will invoke the methods in test.class . How can I specify the test.class file to be used by jar file in command line? Tried many ways, always show: NoClassDefFoundError for test.class NB: the test.class file also use class files in example.jar file, has its own package structure. I know I can put them together in one jar file,

Get all images within directory - within jar file

 ̄綄美尐妖づ 提交于 2019-12-04 05:05:28
问题 I have a folder inside my project that has 238 images. I want to be able to find all images within the directory. I'm currently accessing all these images like this: File directory = new File(FileNameGuesser.class.getResource(DIRECTORY).getPath()); for (File file : directory.listFiles()) { // filter, process, etc. } This works fine within Eclipse. However, when I export to a jar file, FileNameGuesser.class.getResource(DIRECTORY) returns C:\Users\...\file.jar!\org\... (because it's zipped, I

Get file in the resources folder in Java

允我心安 提交于 2019-12-04 04:47:35
I want to read the file in my resource folder in my Java project. I used the following code for that MyClass.class.getResource("/myFile.xsd").getPath(); And I wanted to check the path of the file. But it gives the following path file:/home/malintha/.m2/repository/org/wso2/carbon/automation/org.wso2.carbon.automation.engine/4.2.0-SNAPSHOT/org.wso2.carbon.automation.engine-4.2.0-SNAPSHOT.jar!/myFile.xsd I get the file path in the maven repository dependency and it is not getting the file. How can I do this? SudoRahul You need to give the path of your res folder. MyClass.class.getResource("/res

invalid file (bad magic number): Exec format error

安稳与你 提交于 2019-12-04 04:34:29
I am getting below error when i am trying to set classpath. I am using CentyOS. I am trying to complie a java file in command prompt for that i am setting the classpath. On executing the same java program in Intellij , it runs fine. On executing the same from command prompt it shows error for missing jars so for that i added the classpath to that lib on which the error is seen. [root@a admin]# export CLASSPATH=/home/admin/TagAPI/lib/org.json-20120521.jar ;/home/admin/TagAPI/lib/testng-6.8.21.jar invalid file (bad magic number): Exec format error Any suggestions will be helpful. I am new in

Autowiring classes from external jar with Spring

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 04:28:20
I'm trying to build a standalone application (not running inside an application server) with Spring and I'm facing the following problem : My standalone application (spring enabled) is depending on another project (bundled as a jar) which contains a lot of services in com.application.service (Annotated with @Service ). There is no spring related configuration in the external project and the standalone application context is very simple, it only contains : <context:component-scan base-package="com.application" /> Here is an example of Class that depends on a service which can't be acquired :

Compiling .java files from the command line - external libraries, classpath

女生的网名这么多〃 提交于 2019-12-04 04:21:36
问题 I made a project in Eclipse and am now trying to ensure that the .java files compile from the command line. I've been trying to compile using javac *.java in the folder with all my .java files. However, this results in errors due to a reference to a class from an external library, Joda-time. I have the following .classpath file that Eclipse made for the project but don't know what to do with it. <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/>

Problem compiling in Clojure

柔情痞子 提交于 2019-12-04 04:03:46
I've been trying to compile a very simple test.clj in Clojure without any success. I have a thread on the Clojure Google Group with several responses, but nothing has helped. To quickly summarize, here is my clojure file: (ns test.test (:gen-class)) (defn -main [gre] (println (str "Hello " gre))) Basically it's the example file provided in the Clojure documentation . I have placed this file appropiately in clojure/src/test/test.clj , and should be able to compile with (compile 'test.test) , but I keep getting the error: java.io.IOException: The system cannot find the path specified (test.clj:1

Java - Can't import com.package.*(wildcard)

北慕城南 提交于 2019-12-04 03:42:44
问题 This may be a simple issue, but Google has returned nothing. I have read Help with packages in java - import does not work I still don't understand why a direct import will work but wildcard will not. [EDIT] By class package I mean a package of classes. I am still new to Java so I do not know the semantics [EDIT] I have a class package: com.company.functions , when I try to import com.company.* I receive the following error. java: package com.company does not exist If I import com.company

“Could not find the main class”

血红的双手。 提交于 2019-12-04 03:30:18
问题 I'm trying to run a sample Java application from the command promopt but I'm getting the following error: Exception in thread "main" java.lang.NoClassDefFoundError: com/badlogic/gdx/helloworld/HelloWorldDesktop Caused by: java.lang.ClassNotFoundException: com.badlogic.gdx.helloworld.HelloWorldDesktop at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang

How to set up classpath for the Scala interpreter in a managed environment?

家住魔仙堡 提交于 2019-12-04 03:26:57
问题 I am working on an extension for the Apache Wicket web framework, which lets the user execute code in several programming languages at runtime from the browser. One of these languages is Scala, but I am having trouble when it is bundled as a WAR file and deployed to a container such as Tomcat. When the Scala interpreter is invoked, it refuses to run the code with the following message: Failed to initialize compiler: object scala not found. ** Note that as of 2.8 scala does not assume use of