Results 1 to 9 of 9
  1. #1
    vector_ever is offline Senior Member
    Join Date
    Jul 2013
    Posts
    187
    Rep Power
    2

    Default maven don't support the casting

    Hi,

    i am just new with maven, any way i tried to write a test code, i did every thing, i added every repository and dependency

    but some how i am encounter by a error (understandable error) , that where ist "cast", there is error

    for examble
    Java Code:
    int NewColumn =  (int) col1.get(f);
    i use Eclipse as IDE, and my pom packaging is war

    have any body any idea?

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,079
    Rep Power
    6

    Default Re: maven don't support the casting

    Maven defaults to a very old version of Java, you have to manually configure the Java compiler plugin to compile for Java 7.

    Maven Compiler plugin - Setting the -source and -target of the Java Compiler
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    vector_ever is offline Senior Member
    Join Date
    Jul 2013
    Posts
    187
    Rep Power
    2

    Default Re: maven don't support the casting

    Thanks Erik, but how to manually configure the Java compiler plugin to compile for Java 7???

    which steps should i do?
    do you know any tutorial about this point??

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,079
    Rep Power
    6

    Default Re: maven don't support the casting

    Plenty, all found by using Google. Or you could take the time to browse the online documentation I linked to. To begin with, here is a very minimalistic example pom I ripped from one of my game projects, that is also setup to build an executable jar:

    XML Code:
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>your.group.id</groupId>
      <artifactId>artifactid</artifactId>
      <version>1.0.0-SNAPSHOT</version>
      <name>Your project name</name>
      <description>Your project description</description>
      
      <build>
        <finalName>nameofjar</finalName>
        <sourceDirectory>src/main/java</sourceDirectory>
        <testSourceDirectory>src/test/java</testSourceDirectory>
        <defaultGoal>install</defaultGoal>
        <resources>
          <resource>
            <filtering>false</filtering>
            <directory>src/main/resources</directory>
          </resource>
        </resources>
        <testResources>
          <testResource>
            <filtering>false</filtering>
            <directory>src/test/resources</directory>
          </testResource>
        </testResources>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
              <archive>
                <manifest>
                  <mainClass>your.app.package.MainClass</mainClass>
                </manifest>
              </archive>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <childDelegation>true</childDelegation>
              <useSystemClassLoader>true</useSystemClassLoader>
              <argLine>-Dsun.lang.ClassLoader.allowArraySyntax=true</argLine>
            </configuration>
          </plugin>
          <plugin>  
            <groupId>org.apache.maven.plugins</groupId>  
            <artifactId>maven-compiler-plugin</artifactId>  
            <configuration>  
              <source>1.7</source>  
              <target>1.7</target>  
              <encoding>UTF-8</encoding>
            </configuration>  
          </plugin>  
          <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <configuration>
              <encoding>UTF-8</encoding>
            </configuration>
          </plugin>
        </plugins>
      </build>
    
      <dependencies>
        <dependency>
          <groupId>org.testng</groupId>
          <artifactId>testng</artifactId>
          <version>6.1.1</version>
          <scope>test</scope>
        </dependency>
      </dependencies>
    </project>
    Now what are you going to do? Rip this and change it until it does something, or are you going to spend some time actually trying to learn how to use Maven by using this pom as a guide?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    vector_ever is offline Senior Member
    Join Date
    Jul 2013
    Posts
    187
    Rep Power
    2

    Default Re: maven don't support the casting

    Thanks, any way i search in web and i am recommended to add this part to my pom.xml file:

    Java Code:
    <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                        <showDeprecation>true</showDeprecation>
                        <showWarnings>true</showWarnings>
                        <executable>${env.JAVA_7_HOME}/bin/javac</executable>
                        <fork>true</fork>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    the Problem wehn i did it i got a red cross on the name of the Project (but no error in the same pom.xml) also i delete this plugin but also that red cross stay always.

    what is going on?

  6. #6
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,087
    Rep Power
    20

    Default Re: maven don't support the casting

    Look in your Problems tab in Eclipse and see what it says?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    vector_ever is offline Senior Member
    Join Date
    Jul 2013
    Posts
    187
    Rep Power
    2

    Default Re: maven don't support the casting

    yes thanks i solve it, i just need to update maven project

    another question, now how to run my application in maven project, i create package file in target folder (war file) but how to run and see the result as web application?

  8. #8
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,087
    Rep Power
    20

    Default Re: maven don't support the casting

    Deploy it to a server?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,079
    Rep Power
    6

    Default Re: maven don't support the casting

    Oh I didn't see this was for a web application, if I realized that sooner I would have given more specific information. Time for a bit of self-advertisement then: I actually wrote an article on deploying a JSF 2.x with JPA 2 web application to Tomcat 7, using Eclipse.

    Java Enterprise Stuff: JSF 2.1 and JPA 2 on Tomcat 7

    Perhaps you're not using JSF, but the idea is the same if you're using Wicket, Struts, Spring, whatever.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Replies: 0
    Last Post: 12-17-2012, 01:32 PM
  2. jsf and maven
    By j2me64 in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 02-10-2012, 11:17 AM
  3. Using Maven
    By tascoa in forum New To Java
    Replies: 0
    Last Post: 08-21-2009, 03:45 PM
  4. Replies: 0
    Last Post: 04-20-2009, 06:26 PM
  5. Maven
    By Java Tutorial in forum Java Tutorial
    Replies: 0
    Last Post: 06-02-2008, 12:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •