3

I'm a new user of Raspberry Pi.
Actually, I wanted to buy a Raspberry device when I've finished programming it's software, now I'd like to know that Is it possible? if so, would you provide a sufficient way to program my software on PC (Windows)?
I want to use Java as the programming language.

  • What operating system do you intend to use on the pi? – goldilocks Jul 15 '15 at 20:17
  • @goldilocks a linux-base one, like it's own OS, Raspbian. – Mohsen Salahshoor Jul 15 '15 at 20:59
3

It is possible, but you must take into account, that java is not completely platform independent.

There are lots of examples like linux user limits (ulimit -a shows them) for the amount of max open files, threads / processes, hardcoded filenames with \ (instead of / which works under windows and linux), different behaviour with TCP error handling (i.e. when pulling the RJ45 cable), ... which might cause your program to behave not like under windows.

But most Programs should run out of the box on a Raspberry pi host. In any case you should be able to debug remote your software on the pi from your windows host.

To transfer your binaries to your pi, you can use any sftp/scp client (like the free winSCP or filezilla client).

  • What is the best way to do such a thing in your idea? – Mohsen Salahshoor Jul 17 '15 at 6:57
2

Yes you can write your Java Program on a PC and transfer the compiled .jar to the Raspberry Pi and run it there.

I use maven to manage my Project like that. Add this to your pom.xml for automated transfer. You could also do this "by hand" via an usb-stick or winSCP for example. But this automates the copy on every build:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>

        <!-- this is used to package an executable .jar -->
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <finalName>executable_name</finalName> <!-- set the exported name Here -->
                <appendAssemblyId>false</appendAssemblyId>
                <archive>
                    <manifest>
                        <mainClass>package.MainClass</mainClass> <!-- set Main class here -->
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id> <!-- this is used for inheritance merges -->
                    <phase>package</phase> <!-- bind to the packaging phase -->
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <!-- this is used to transfer the compiled .jar to the raspberry pi -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <executions>
                <execution>
                    <id>server-copy</id>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <phase>package</phase>
                    <configuration>
                        <target>
                            <echo message="Push to server/home/pi/foldername" />
                            <!-- destination folder to copy into  user:password@ipaddress:/folder/pah -->
                            <scp trust="yes" todir="pi:raspberry@192.168.0.1:/home/pi/foldername">
                                <fileset dir="${basedir}/target">
                                    <!-- name declared above in "finalName" -->
                                    <include name="executable_name.jar" />
                                </fileset>
                            </scp>
                        </target>
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>org.apache.ant</groupId>
                    <artifactId>ant-jsch</artifactId>
                    <version>1.8.2</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.