classpath

Java dynamically load plugin

元气小坏坏 提交于 2019-12-04 12:08:43
问题 I want to make an application that can dynamically load plug-ins but I've not found any literature on Internet. The difficult thing is: I don't know the name in advance. For example I've a Plugin interface: public interface Plugin { public static Plugin newPlugin(); public void executePlugin(String args[]); } So that every Class implementing Plugin in the jar file are instantiated in a list: Method method = classToLoad.getMethod ("newPlugin"); mylist.add(method.invoke(null); First problem is,

Adding JAR to CLASSPATH in Mac OS

南笙酒味 提交于 2019-12-04 12:07:38
问题 This question was migrated from Super User because it can be answered on Stack Overflow. Migrated 8 years ago . I am trying to set up the CLASSPATH for Java under Mac OS. Specifically I am trying to add a couple of JAR archives to it. If I do it like: ## Setting up ASM bytecode instructor library export CLASSPATH=$CLASSPATH:/Users/fork/Dev/ASM/lib/all/asm-all-3.3.1.jar It works fine. However, if I set it like the documentation recommends: ## Setting up ASM bytecode instructor library export

Getting ClassNotFoundException on code: “Class.forName(”com.microsoft.sqlserver.jdbc.SqlServerDriver“);”

↘锁芯ラ 提交于 2019-12-04 12:04:26
This is my first Java application and I'm completely inexperienced with Java and NetBeans . I have been trying to connect to sql and get some records for 2 days. The problem is about jdbc driver, let me explain. I have downloaded sqljdbc driver and then followed these steps: Right-click Project->Select Properties->On the left-hand side click Libraries->Under Compile tab - click Add Jar/Folder button and select sqljdbc4.jar file. Then it should be ok, right? Then I wrote this code But I cant get rid of this exception: Exception in thread "main" java.lang.ClassNotFoundException: com.microsoft

Java runtime ClassNotFoundException

99封情书 提交于 2019-12-04 11:57:57
Just had a question about an odd runtime error that I'm having. I'm working with a JSON server that responds with a JSON object when prompted by an outside source. As of right now, however, I'm simply trying to get the JSON object up and running before sending it out. My code compiles without specifying any classpath, but when it comes to runtime, it throws a NoClassDefFoundError as seen here: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader

access common property file inside bundle with osgi

自作多情 提交于 2019-12-04 11:47:50
I have an osgi application (in felix) with multiple bundles. There are some common property files in one bundle and the rest of the bundles need just use them. We use maven and spring osgi, the property files are in resouces like: <path to bundle>/src/main/resources/ common.properties engine.properties ... Maven builds them inside the bundle jar normally so they should be in an application classpath, but Spring has no access to them, this fails: <context:property-placeholder location="classpath:common.properties" /> (tried classpath*: and other combinations) I've read this and this Is it

classpath - running a java program from the command line

人盡茶涼 提交于 2019-12-04 11:24:50
My code compiled fine with the following command: javac -cp "../lib/*" AvroReader.java (lib is where i put my jar files) At run time I get a ClassNotFoundException on the following line: DatumReader<?> dtmrdr = new GenericDatumReader(); It says it can't find org.apache.avro.generic.GenericDatumReader even though I've imported it. Why this is happening? Thanks! Importing has nothing to do with loading classes or setting CLASSPATH. Try this: java -cp .;../lib/* Generator Using the dot '.' as the first entry in the CLASSPATH assumes that the Generator.class file exists in the directory from which

How do I add an icon as a classpath resource to an SWT window created with WindowBuilder?

荒凉一梦 提交于 2019-12-04 10:32:14
问题 I'm trying to add an external icon from an *.ico file to a window that I'm creating using the WindowBuilder design window. I can select the shell, which brings up an "image" properties field. That brings up the image chooser dialog box: How do I make my icon show up in this menu as a classpath resource? The image works if an absolute path is given, but I don't want to use that option in my application. Thanks! 回答1: To easily add an icon to my classpath, I found my desired icon, right clicked

how to check if a jar file is valid?

五迷三道 提交于 2019-12-04 10:31:21
问题 my webapp allows a user to upload a jar file. however, after the jar file is uploaded, it is corrupted. i have verified this by comparing the md5 checksum (winmd5free). the uploaded jar file looks "normal" and "right" the file size compared to the original looks right (at the KB level) i can open the uploaded jar file using 7z and view its content (resources and class files), and everything is the same compared to the original when i open up the uploaded jar file (using Notepad++), i did

How to override ant task stored in ant lib directory

喜欢而已 提交于 2019-12-04 10:15:49
At my work we use AspectJ in some of our Java projects. To get this to work with ant builds we have been placing aspectjtools.jar within ant/lib/. I am now working on a particular Java project and need to use a newer version of aspectJ. I don't want to have to get everyone who uses the project to update their local copy of aspectjtools.jar. Instead, I tried adding the newer aspectjtools.jar to the lib directory of the project and adding the following line to build.xml. <taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties" classpath="./lib/aspectjtools.jar" /> However,

Using maven 3, how to use project classpath in a plugin?

三世轮回 提交于 2019-12-04 09:54:44
I'm writing a maven 3 plugin, for which I would like to use project classpath. I've tried using the approach mentionned in Add maven-build-classpath to plugin execution classpath , but it seems the written component is not found by maven. (I have a ComponentNotFoundException at plugin execution start). So, what is the "reference" way to use project classpath in a maven 3 plugin ? Or if the component way is the right one, is there any configuration step beside adding the component as configurator property of the @Mojo annotation ? You can retrieve the classpath elements on the MavenProject by