I ran the "hello world" app without swt at cmd to println and it printed out the msg, so it can see my class in the jar. The syntax below is complaining about swt. It is interesting that I tried a few things:
1.) redindex the repository
2.) go to window show view and rebuild index. At first my jars weren't showing, and now they are.
3.) I started fresh with a new Maven project because the other one might be tainted, as I was newer at this.
I did a echo %M2_REPO% and it printed out the right location.
I did a manifest display with jar -tf my-app2-0.0.3-SNAPSHOT.jar
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: com.thirdshiftcoder.derbyApp.Table_Demo. Program
my pom is here:
located in .m2
The path to the offending jar generating a msg. when I try to run my program absolute path to SWT is c:\Users\mtdew3q\.m2\repository\swt\swt\4.3.0\swt-4.3.0.jar. Of note, there was never really a version when that jar came from the web. It just said swt.jar. That was the right version, but from the web the version wasn't included in the file name.
I am at my wits end. I can't get maven to recognize that SWT is in the local repository. If I can't include it with build_path, how in the world can I get it to recognize it is HERE in the local repo? I am also confused because it says maven dependencies in my project but it seems to be doing nothing.
When I run this as a java project from within eclipse a shell with a tbl shows with my data from derby displayed.
I know I said I'd wait to post, but I have some time off for election day and tried to give it another whirl. I have fun doing this, but I need a little break through on this one to keep me going.
If I can get this to recognize the local repo, I will think this is the coolest thing since cold sliced pizza.
If you are installing fine then maven is seeing your swt jar. Your problem is when running the program which doesn't involve maven at all.
Is your application going to be distributed as a jar? Where are you going to put the dependent jars that should be part of the classpath?
You can tell maven to generate a jar with an arbitrary classpath by adding manifestEntries to your maven-jar configuration. This will result in a jar that may or may not work depending on whether path.to.the.swt.and.other.jars exists or not on the machine where it is run. So basically your maven seems happy, it's just your distribution of your application that you need to think about and plan and then tell maven how you want it done.
Hi, I just noticed something cool I didn't see before. I wasn't using the pom editor in m2 for eclipse. Now I figured out to get a repository and search for my jars from the repository. So now I have the repository the way I want it. There is a dependency tab and all my jars show up there. Before they weren't.
Now I don't to download and unzip 3rdparty jars very often.I know I have the jars and they are in the local repository so why can't I run the project from outside of eclipse?
oh well. I will keep after it and try to figure this out. I am going to try to search for a video on how to run a maven project from the command line. I think tonight I will relax and go book shopping and read manuals on the web. I just need to keep reading stuff. I am going to figure out how to deploy my app so I don't need eclipse open to run it.
Can't you use the local .m2/repository and have eclipse recognize all those jars when deploying the app? I read about one jar but I noticed the xml is different and the one jar sample article was old with maven.
I don't have a very high level of using tools. For instance I just learned jar -tf or jar xf. That way I could check the manifest file contents after extracting the files.
Thanks for sticking with me. I looked at the manifest as one poster asked, and I saw that all the dependent jars were included, so I dumped all the dependent jars in a directory and added the jar in target maven makes in that same directory. Now I am getting a different error msg. but it is because for a different reason. I think soon I will be running the app.
my cmd line to run is c:\Users\mtdew3q\.m2\repository\xf> java -jar myapp-version.snapshot.jar com.thirdshiftcoder.derbyApp Table_Demo
Just keep in mind that maven is intended to help while you are developing your application and while assembling your target (runnable) artifact.
It is not intended to help with starting or running the application. Depending on who your application users are, they may not even have maven installed. So where to put the dependencies for running your application will depend on how you intend to distribute your application to the end users which you haven't specified yet.
Thanks for all your help E. Your the best! I am learning to deploy now and from your tips figuring out where m2 plug-in and maven fit in. It is very cool to use. I really did like fatjar with onejar but fatjar was always so slow. I think this way is faster. I like how you can select from more than one repository and can also install 3rd party jars from the command line to the repository for those ones you need that aren't available in the repository. I did that with something I couldn't find elsewhere after using 2 repositories. I believe it was a jpa jar for hibernate. JPA was a requirement for deploying my hibernate app, but I couldn't find the right jar in the maven of jboss repo.
I am so glad I stuck it out. There was one night that nothing went right, and a few expletives were abound, but then I put on my rally cap.