NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Running NetBeans Maven Projects Externally

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
genericprodigy



Joined: 05 Aug 2009
Posts: 13

PostPosted: Wed Aug 05, 2009 8:31 am    Post subject: Running NetBeans Maven Projects Externally Reply with quote

I've been working on a NetBeans Maven project for a couple of weeks - the reason I chose Maven was for the simplicity of moving between IDEs and having a process that was IDE free for builds - my team is not Java oriented and thus are not convinced enough to install NetBeans.

However, I cannot run the Maven project outside of NetBeans. I get the, reasonably common, 'Bad version number in .class file'. I half expected the Maven POM to just run when I tried 'mvn assembly::assembly' but no such luck.

The final assembly created cannot be executed either. I tried to create an assembly with dependencies, which looks successful (I added a new Action in the Project Properties that runs 'assembly::assembly'), but I cannot figure out how to get this to correctly set my MANIFEST.MF file to define my Main Class.

If my POM is required, then just ask.

I'm using NetBeans 6.7 at the moment.

Regards,

Gen.
Back to top
mkleint
Posted via mailing list.





PostPosted: Thu Aug 06, 2009 6:24 am    Post subject: Running NetBeans Maven Projects Externally Reply with quote

genericprodigy wrote:
Quote:
I've been working on a NetBeans Maven project for a couple of weeks - the reason I chose Maven was for the simplicity of moving between IDEs and having a process that was IDE free for builds - my team is not Java oriented and thus are not convinced enough to install NetBeans.



However, I cannot run the Maven project outside of NetBeans. I get the, reasonably common, 'Bad version number in .class file'. I half expected the Maven POM to just run when I tried 'mvn assembly::assembly' but no such luck.


Bad version in class file probably means that the jdk you run the build
with is 1.4 and one of the dependencies contains 1.5 class files? Or
something along those lines, it sounds like a JDK related problem not
directly netbeans or maven one.
Quote:


The final assembly created cannot be executed either. I tried to create an assembly with dependencies, which looks successful (I added a new Action in the Project Properties that runs 'assembly::assembly'), but I cannot figure out how to get this to correctly set my MANIFEST.MF file to define my Main Class.


I think the manifest main class is setup in the maven-jar-plugin
configuration.

Milos
Quote:

If my POM is required, then just ask.



I'm using NetBeans 6.7 at the moment.



Regards,



Gen.




Back to top
genericprodigy



Joined: 05 Aug 2009
Posts: 13

PostPosted: Thu Aug 06, 2009 8:20 am    Post subject: Re: Running NetBeans Maven Projects Externally Reply with quote

Quote:

Bad version in class file probably means that the jdk you run the build
with is 1.4 and one of the dependencies contains 1.5 class files? Or
something along those lines, it sounds like a JDK related problem not
directly netbeans or maven one.


That would make sense, if it were not for the fact NetBeans has no problem running it under 1.6 and yet, although java -version reveals the same JDK, the command line execution of the same Maven POM produces that error.

Is there anywhere else I should check to enforce this?

Thanks for your advice so far.

I have fixed the issue of the executable JAR not working correctly by the way - for anyone experiencing that same issue, it was fairly obvious once I found it!

In my POM I had set the manifest details to be set when building the JAR package, but not for creating the Assembly. I assumed, wrongly, that the Assembly would take the JAR package details and add dependencies.

Here's a copy of the section of the POM that was relevant:

Code:

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>com.mycompany.MyMainClass</mainClass>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRefs>jar-with-dependencies</descriptorRefs>
                    </descriptorRefs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>com.mycompany.MyMainClass</mainClass>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>


G.
Back to top
mkleint
Posted via mailing list.





PostPosted: Thu Aug 06, 2009 11:41 am    Post subject: Running NetBeans Maven Projects Externally Reply with quote

genericprodigy wrote:
Quote:


Quote:
Bad version in class file probably means that the jdk you run the build



Quote:
with is 1.4 and one of the dependencies contains 1.5 class files? Or



Quote:
something along those lines, it sounds like a JDK related problem not



Quote:
directly netbeans or maven one.







That would make sense, if it were not for the fact NetBeans has no problem running it under 1.6 and yet, although java -version reveals the same JDK, the command line execution of the same Maven POM produces that error.



Is there anywhere else I should check to enforce this?


hmm.. have you done a clean build? if so then it's something in your
dependencies (maybe wrong jar/zip file?)
have you double checked that the JAVA_HOME points to the same jdk and
the PATH also points to the same jdk instance?

Milos
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo