classpath

Spark-submit ClassNotFound exception

廉价感情. 提交于 2019-12-18 11:49:47
问题 I'm having problems with a "ClassNotFound" Exception using this simple example: import org.apache.spark.SparkContext import org.apache.spark.SparkContext._ import org.apache.spark.SparkConf import java.net.URLClassLoader import scala.util.Marshal class ClassToRoundTrip(val id: Int) extends scala.Serializable { } object RoundTripTester { def test(id : Int) : ClassToRoundTrip = { // Get the current classpath and output. Can we see simpleapp jar? val cl = ClassLoader.getSystemClassLoader val

Java Spring - How to use classpath to specify a file location?

陌路散爱 提交于 2019-12-18 11:41:21
问题 How can I use the classpath to specify the location of a file that is within my Spring project? This is what I have currently: FileReader fr = new FileReader("C:\\Users\\Corey\\Desktop\\storedProcedures.sql"); This is hardcoded to my Desktop. What I would like is to be able to use the path to the file that is in my project. FileReader fr = new FileReader("/src/main/resources/storedProcedures.sql"); Any suggestions? 回答1: Are we talking about standard java.io.FileReader? Won't work, but it's

Loading velocity template inside a jar file

我的梦境 提交于 2019-12-18 10:26:42
问题 I have a project where I want to load a velocity template to complete it with parameters. The whole application is packaged as a jar file. What I initially thought of doing was this: VelocityEngine ve = new VelocityEngine(); URL url = this.getClass().getResource("/templates/"); File file = new File(url.getFile()); ve = new VelocityEngine(); ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "file"); ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, file.getAbsolutePath()); ve

Setting classpath for a JAR

扶醉桌前 提交于 2019-12-18 09:13:28
问题 I have a standalone java project. I have performed a maven clean install. I now go into the target\classes folder via command prompt and set all the required files in classpath. Now I execute the main class. The result is being displayed. Now I move back to target folder via command prompt and try to execute the jar file (jar file has a manifest file where the main class is defined). Java -cp %CLASSPATH% -jar Destination-01.19-SNAPSHOT.jar Now I get the below exception. I have also removed

RxTx installation on windows java.lang.NoClassDefFoundError: gnu/io/CommPort

泄露秘密 提交于 2019-12-18 07:07:30
问题 I put rxtxcomm.jar into jre/lib/ext folder, but I still get NoClassDefFoundError Isn't this folder automatically taken into the global classpath? Thanks 回答1: yes it is taken automatically to classpath, but RXTXcomm uses JNI /native external libraries (.so and .dll files), you must provide the path to them when running your program in command line: java -jar yourprogram.jar -Djava.library.path="PATH_TO_EXTERNAL_LIBRARIES" for linux: suppose you unpacked the rxtx.zip to /home/user/ if you have

Use java in matlab

左心房为你撑大大i 提交于 2019-12-18 06:50:36
问题 I encountered a problem when I tried to use java from matlab. I read through the tutorials from MathWork.com several times, also I re-installed the JDK1.6, in order to be compatible with matlab. However, after my work, it still doesn't work... Here is the contents in classpath.txt: C:\Program Files\MATLAB\R2010a\java\jarext\xstream.jar C:\Program Files\MATLAB\R2010a\toolbox\javabuilder\jar\win64 \javabuilder.jar DYNAMIC JAVA PATH C:\Users\Gao\Desktop\connected_components_labeling Clearly, the

Use java in matlab

狂风中的少年 提交于 2019-12-18 06:50:34
问题 I encountered a problem when I tried to use java from matlab. I read through the tutorials from MathWork.com several times, also I re-installed the JDK1.6, in order to be compatible with matlab. However, after my work, it still doesn't work... Here is the contents in classpath.txt: C:\Program Files\MATLAB\R2010a\java\jarext\xstream.jar C:\Program Files\MATLAB\R2010a\toolbox\javabuilder\jar\win64 \javabuilder.jar DYNAMIC JAVA PATH C:\Users\Gao\Desktop\connected_components_labeling Clearly, the

getClass().getClassLoader().getResourceAsStream() is caching the resource

早过忘川 提交于 2019-12-18 05:43:46
问题 I have a resource (velocity template) which I'd like to be able to swap during development. However, getClass().getClassLoader().getResourceAsStream() seems to cache the template. Is there a way to disable this besides using a file loader instead of the class loader? 回答1: To avoid caching you can use: getClass().getClassLoader().getResource().openStream() It would be equal to using URLResourceLoader for Velocity instead of ClasspathResourceLoader I suppose. I would just go with a file loader.

Can I use the classpath to override a file in a jar that is being run?

只愿长相守 提交于 2019-12-18 05:34:28
问题 I have a JAR file that contains an application as well as configuration files for that application. The application loads configuration files from the classpath (using ClassLoader.getResource() ), and has its dependencies completely satisfied using the configuration files baked into the JAR file. On occasion I want the application to be run with a slightly different configuration (specifically I want to override the JDBC URL to point to a different database) so I create a new configuration

Hive error : Exception in thread “main” java.lang.NoClassDefFoundError: scala/collection/Iterable

六眼飞鱼酱① 提交于 2019-12-18 05:13:18
问题 I am facing an error when I try to query a table in hive when hive uses spark. For example, when I do: select count(*) from ma_table; I get this: Exception in thread "main" java.lang.NoClassDefFoundError: scala/collection/Iterable at org.apache.hadoop.hive.ql.parse.spark.GenSparkProcContext.<init>(GenSparkProcContext.java:163) at org.apache.hadoop.hive.ql.parse.spark.SparkCompiler.generateTaskTree(SparkCompiler.java:195) at org.apache.hadoop.hive.ql.parse.TaskCompiler.compile(TaskCompiler