I have a Java  command-line-application, which creates a report file after running some steps defined in the source-code. Now I want to separate those steps from the core functionality of my application, because I want that the  application can run dynamically loaded "steps". This means, the core functionality of my application is to create the report file. And the separated "steps" should provide the content of the report.  I decided to realize those steps as plug-ins in my application. Everyone, who uses  the application can extend it with already existing or own written plug-ins.  Now my question is, what is the best way - in my case - to develop a plug-in system for my application? I researched a lot and got to much input. I can't decide how should I resolve the problem.  Interesting question from SO:       During my research I collected some informations how i could resolve it:   Using ServiceLoader: a simple service-provider loading facility. Using org.openide.util.Lookup from NetBeans(dynamic registration and lookup of components) Defining a own Plug-in interface, which must be implemented from the plug-ins. And then using the Java ClassLoader to  load those classes and create instances of them. Using OSGi, but I think it is to "big" for my purpose.   What is the best way to solve my problem with:   a elegant plug-in architecture (perhaps with use of some design patterns), easy to maintain source-code, and easy to develop plug-ins.   Is my approach with a plug-in system correct? Or is there something else what could i use?
39711
How would you implement a Plugin-system for your Java application?  Is it possible to have an easy to use (for the developer) system which achieves the following:   Users put their plugins into a subdirectory of the app The Plugin can provide a configuration screen If you use a framework, is the license compatible with commercial developement?
123877
I'm writing a java app using eclipse which references a few external jars and requires some config files to be user accessable.   What is the best way to package it up for deployment? My understanding is that you cant put Jars inside another jar file, is this correct? Can I keep my config files out of the jars and still reference them in the code? Or should the path to the config file be a command line argument? Are there any third party plugins for eclipse to help make this easier? I'm using an ant build file at the moment but I'm not sure I know what I'm doing. Is there an equivelent of the deployment projects in Visual studio, that will figure out everything you need and just make an installer? I've used install4j before, and it was powerful if no where near as automated as  .Net deployment projects.   Cheers.
56518
I'm a Java developer by trade. I was 'brought-up' in what you could call best practices. Then I took my current job. I had a choice between the Java/SOA team, and the ERP team. I was told that joining the ERP team would give me the best insight into how the business operates (not in terms of technology, but in terms of business.) So I went with ERP.  I found a system with over 4 million lines of "Progress 4GL" code (since renamed to Openedge ABL, because "4GLs sound bad") code, spread out around about 11000 files. The best part is, no file exists more than one folder down. So you have about 50 folders, each with 300-400 files a piece in them. Luckily, many of the files haven't been touched in over 7 years, and many of them are deprecated (but we don't delete them from version control "just in case." Don't even get me started on that one.) So there's really only about 1.5 million lines of code we'd actually have to test. "Only."  I could go on and on about the poor practices of the system. The bottom line was for years, developers had no option to say no. It was "gimme gimme gimme," combined with a lot of contractors moving in and out. Now, they want to clean up their act.  One of the first things I suggested was testing. They said, basically "we've been wanting to do testing for years, but we don't really know where to start." The business logic and database access are baked into the UI. (I'd say GUI, but it's not graphical, it's on a mainframe. Even the order-entry people telnet in.)  So this is pretty much a worst case scenario. Millions of lines of code. Over a billion dollars in annual sales running through the system, so it's not going to get a re-write (obviously "it works as it is.") No object orientation. No formal or automated tests. Our testers are also the ones who write the specs (which biases them toward "pushing the project through.")  I'm getting pretty desperate. I'm even willing to write whatever testing frameworks (there isn't much for Openedge in open source frameworks) we need on my spare time. I'm convinced it will pay for itself quite quickly. Where can we start? Has anyone here come across a similar project (even if smaller in scale) and if so, how did you cope with and overcome this?  Update: I've had a chat with my manager, and I have approval to draw up a spec/timeline for creating a test harness. At first, I heard this: "What we really need to do is write some tests." to which I responded "Having tests won't really help us if we don't have a way to run them. I've been looking into ProUnit (the old name for OEUnit) and think it will work for us." "We should write some tests using it." It took about 10 minutes of repeating this for him to realize it was not as simple as downloading the library and "using it." But, approval to write a spec to create a test harness is a start! Thanks guys for all your input!
61570
I would like to know what would be the best way to do unit testing of a servlet.   Testing internal methods is not a problem as long as they don't refer to the servlet context, but what about testing the doGet/doPost methods as well as the internal method that refer to the context or make use of session parameters?  Is there a way to do this simply using classical tools such as JUnit, or preferrably TestNG? Did I need to embed a tomcat server or something like that?
12184
I'm trying to get an understanding of what the the java keyword this actually does. I've been reading Sun's documentation but I'm still fuzzy on what this actually does.
37283
I'm launching a Weblogic application inside Eclipse via the BEA Weblogic Server v9.2 runtime environment. If this were running straight from the command-line, I'd do a ctrl-BREAK to force a thread dump. Is there a way to do it in Eclipse?
97558
I've been trying to install the Java plugin for Chrome for a couple hours now, and I figured it was time to ask people with more experience. I can't seem to get it working. My current Java version is the 64-bit OpenJDK 1.6.0_24. I tried installing the IcedTea plugin to no avail. I have Ubuntu 12.04 64-bit installed at the moment.  When I tried testing if java was enabled in Chrome, any website with a Java applet would not load (when I disabled the plugin, they loaded, but not the applet).  I followed the instructions from here:   which said to create this script and run it:  JAVA_HOME=/usr/lib/jvm/jdk1.7.0 MOZILLA_HOME=~/.mozilla mkdir $MOZILLA_HOME/plugins ln -s $JAVA_HOME/jre/lib/i386/libnpjp2.so $MOZILLA_HOME/plugins   Note: You may need to change the value of JAVA_HOME so that it correctly points to your installation of the JDK. 64-bit users will need to change the final line to:   ln -s $JAVA_HOME/jre/lib/amd64/libnpjp2.so $MOZILLA_HOME/plugins   but this did not work as well.  I just test it in Firefox and it's working. Still nothing for Chrome
77007
I have a large codebase without Javadoc, and I want to run a program to write a skeleton with the basic Javadoc information (e.g., for each method's parameter write @param...), so I just have to fill the gaps left.  Anyone know a good solution for this?  Edit:  JAutodoc is what I was looking for.  It has Ant tasks, an Eclipse plugin, and uses Velocity for the template definition.
57210
I've compiled a java project into a Jar file, and am having issues running it.  When I run:  java -jar myJar.jar   I get the following error  Could not find the main class: myClass   The class file is not in the root directory of the jar so I've tried changing the path of the main class to match the path to the class file and I get the same issue.  Should I be flattening the file structure? if so how do I do this. I'm using Ant to build the Jar file if thats of any use.  UPDATE   Here is the contents of the jar and the relevant Ant sections, I've changed the name of the firm I work for to "org":  META-INF/ META-INF/MANIFEST.MF dataAccessLayer/ dataAccessLayer/databaseTest.class org/ org/eventService/ org/eventService/DatabaseObject.class org/eventService/DatabaseObjectFactory.class org/eventService/DbEventClientImpl$HearBeatMonitor.class org/eventService/DbEventClientImpl.class org/eventService/EmptyQueryListException.class org/eventService/EventHandlerWorkItem.class org/eventService/EventProcessor.class org/eventService/EventTypeEnum.class org/eventService/EventWorkQueue$MonitorThread.class org/eventService/EventWorkQueue$PoolWorker.class org/eventService/EventWorkQueue.class org/eventService/FailedToLoadDriverException.class org/eventService/IConnectionFailureListener.class org/eventService/InvalidEventTypeException.class org/eventService/JdbcInterfaceConnection.class org/eventService/NullArgumentException.class org/eventService/OracleDatabaseObject.class org/eventService/ProactiveClientEventLogger.class org/eventService/ProactiveClientEventLoggerException.class org/eventService/PropertyMap.class org/eventService/SQLServerDatabaseObject.class org/eventService/TestHarness.class org/eventService/Utilities.class   And the ant target:  &lt;target name="compile" depends="init" description="compile the source "&gt;     &lt;javac srcdir="src" destdir="bin" classpathref="project.class.path"/&gt; &lt;/target&gt; &lt;target name="buildjar" description="build jar file" depends="compile"&gt;     &lt;mkdir dir="dist"/&gt;     &lt;jar destfile="dist/myJar.jar" basedir="bin" includes="**/*.class" &gt;         &lt;manifest&gt;             &lt;attribute name="Main-Class" value="org.eventService.ProactiveClientEventLogger"/&gt;         &lt;/manifest&gt;      &lt;/jar&gt; &lt;/target&gt;
83082
I'm finding it difficult to phrase this question well, as there are quite a few generic terms (run, configuration, launch, etc.). Here goes:  You can . (in the Run Configuration Dialog, under the Common tab, Save as a shared file.  We check these in to SVN. The developers can pass them around, and it helps getting new devs running a working application quicker.  I'd like to check these out as part of our build and use them to programatically run the application, the tests, etc, without spinning up the whole IDE.  What would be the best way to run a .launch file outside of the UI?   Edit: I am trying to unify the tests run on the build server and the IDE. I do not  particularly want to give up integrated debugging, which would be the case with an ant script to run the tests .  This is probably more a problem for integration testing with multiple bundles, or unit testing a whole bundle, where you'd like to mock up extensions.
19866
When running a Java app from eclipse my ImageIcon shows up just fine.  But after creating a jar the path to the image obviously gets screwed up.  Is there a way to extract an image from the jar at runtime so I can then open it up?  Or, is there a better way to do this?  I'd like to distribute a single jar file if possible.
72822
NOTE The audience of programmers.se and dba.se is different, and will have different viewpoints, so in this instance I think it's valid to duplicate  on programmers.se.  I couldn't find discussion on dba on this already, and the original post says it all, so:     Most software developers want to keep   application logic in the application   layer, and it probably feels natural   for us to keep it here. Database   developers seem to want to put   application logic in the database   layer, as triggers and stored   procedures.      Personally I would prefer to keep as   much as possible in the application   layer to make it easier to debug and   keep the responsibilities of the   layers separate.      What are your thoughts on this, and   what should or should not be ok to   implement in the database layer?   N.B. I'm not the OP for that question, but left the original wording intact.
120463
I have a problem: imagine I have a plugin-based system.  I need some kind of interface with which I could catch events from every plugin, which implements for example IReporting interface.  (IReporting) object.OnSomeEvent += &lt;.....&gt;   But I can't find a way to do that.
74718
The business purpose is that I allow registered user upload different 3D model files. When other users review the file, he or she does not need to download the whole file (size about several Gbs), he or she could make preview the 3D model files with the biginning a couple of 3D frames. In this way, he or she could know about the 3D file roughtly, then decide to download or not.  Since the 3d format file is around several Gbs, I could not load the file at once. But I only know the following way of loading a file:  import bpy  bpy.ops.wm.open_mainfile(filepath="E:/sjj/Blender/demoFile/Demo_274/Ring_27.blend"   The expert in  suggests me following:     You could try appending items from the large file into a new file.   But, I do not know how to appending items from the large file into a new file. I checked  in this forum, it needs graphical UI. With my business purpose, it allow me only uses command line script.   Could some expert show me the code examples?
81192
During development (and for debugging) it is very useful to run a Java class' public static void main(String[] argv)  method directly from inside Eclipse (using the Run As context menu).  Is there a similarily quick way to specify command line parameters for the run? What I do now is go to the "Run Dialog", click through the various settings to the tab where I can specify VM and program arguments and enter them there.  Too many steps, plus I do not want to mix the more permanent runtime configuration settings with the one-off invokation parameters. What I want instead is to check a box somewhere (or have a separate menu item "Run as Java application with command line") and then be prompted for the commandline every time (with a nice history).
81239
I'm a C++ developer - not a java developer, but have to get this code working...  I have 2 public classes that will be used by another product.  I used the package directive in each of the java files.    package com.company.thing;  class MyClass ...   When I try to compile a test app that uses that I add   import com.company.thing.*;   The javac compiler fails with errors about com.company does not exist.  (even if I compile it in the same directory as the class files I just made a package of)  I am sure I am doing something bone-headed and silly.  I've read the  pages and tried to set up a directory structure like /com/company/thing  etc, but either I have totally screwed it all up or am missing something else.  EDIT thanks for the suggestions - I had tried the classpath previously.  It does not help.  I tried compiling   javac -classpath &lt;parent&gt; client.java    and the result is:  package com.company does not exist   I have the code I want to import (the two java files) in \com\company\product.  I compile those fine.  (they contain MyClass) I even made a jar file for them.  I copied the jar file up to the parent directory.  I then did (in the parent directory with the client java file)   javac -cp &lt;jarfile&gt; *.java   the result is:  cannot access MyClass bad class file: MyClass.class(:MyClass.class) class file contains wrong class: com.company.product.MyClass Please remove or make sure it appears in the correct subdirectory of the classpath.   EDIT  I got the client code to compile and run if I used the fully qualified name for MyClass and compiled it in the parent directory.  I am totally confused now.    compiled with no classpath set - just   javac *.java    in the parent directory - and it worked fine.  I can get a test app to compile, but that is not going to cut it when i have to integrate it into the production code.  Still looking for help.  EDIT:  Finally - not sure why it didn't work before - but I cleaned up all the files all over the directory structure and now it works.    Thanks
37207
Sometime I see many application such as msn, windows media player etc that are single instance applications (when user executes while application is running a new application instance will not created).  In C#, I use Mutex class for this but I don't know how to do this in Java.