Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » executing programs
executing programs [message #205016] Sun, 15 April 2007 15:46 Go to next message
Eclipse UserFriend
Originally posted by: steven.revimmo.com

Hi,

I'm TOTALLY new to java and thus eclipse;-)

I've written a first little app (using jasperreports, to run a report into
a pdf file).
It runs just fine in eclipse.
It produces files and a directory structure as follows:
bin : class file
lin : all the jars I need for the app
src : the source files

BUT... The simplest thing : just run my app from the command line does not
work.
If I move into the bin directory and do 'java myclassname' it does not
work.
I've tried all kind of commands (without knowing what i'm doing) nothing
works.
I studied the tutorials from sun, no information, just humbug.
I searched the help from eclipse: NO information what's ever on running
programs.
I suppose I must indicate the libraries (jars ?) somehow, who are in my
lib directory.
Could anyone simply tell me how to run a java app ?

Thanks in advance,
Steven
Re: executing programs [message #205039 is a reply to message #205016] Sun, 15 April 2007 16:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dtoland.email.uophx.edu

You will need a classpath in order for the Java engine to find the classes used by your
program. It helps to have a CLASSPATH environment variable listing all the class roots
used for all your Java applications. Any other class libraries or project roots you need can be
specified in -classpath arguments to the java command.

Look in the .classpath file at the root of your project directory to see what your classpath
requires for your program to run.

Keep in mind that your class that defines main must also be in the classpath, so '.' is
useful in the classpath. Also, if your main class is in a package path, the classpath component
must point to the root of the package path. For instance, if your main is in net.mydomain.MyApp,
your MyApp.class must reside in the folder ./net/mydomain relative to a folder in your classpath.

--
Dave Toland
dave.toland@verizon.net

"Steven" <steven@revimmo.com> wrote in message news:2d341cb12a8aa0ee2e7289d69ec92489$1@www.eclipse.org...
| Hi,
|
| I'm TOTALLY new to java and thus eclipse;-)
|
| I've written a first little app (using jasperreports, to run a report into
| a pdf file).
| It runs just fine in eclipse.
| It produces files and a directory structure as follows:
| bin : class file
| lin : all the jars I need for the app
| src : the source files
|
| BUT... The simplest thing : just run my app from the command line does not
| work.
| If I move into the bin directory and do 'java myclassname' it does not
| work.
| I've tried all kind of commands (without knowing what i'm doing) nothing
| works.
| I studied the tutorials from sun, no information, just humbug.
| I searched the help from eclipse: NO information what's ever on running
| programs.
| I suppose I must indicate the libraries (jars ?) somehow, who are in my
| lib directory.
| Could anyone simply tell me how to run a java app ?
|
| Thanks in advance,
| Steven
|
|
Re: executing programs [message #205061 is a reply to message #205039] Sun, 15 April 2007 17:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: steven.revimmo.com

Hi Dave,

Thanx for your help, but it did not work.

Here is my .classpath :
------------------------------------------------------------ ---------------
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/commons-beanutils-1.7.jar"/>
<classpathentry kind="lib" path="lib/commons-collections-2.1.jar"/>
<classpathentry kind="lib" path="lib/commons-digester-1.7.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-1.0.2.jar"/>
<classpathentry kind="lib"
path="lib/commons-logging-api-1.0.2.jar"/>
<classpathentry kind="lib" path="lib/itext-1.3.1.jar"/>
<classpathentry kind="lib" path="lib/jasperreports-1.3.1.jar"/>
<classpathentry kind="lib"
path="lib/mysql-connector-java-3.1.11-bin.jar"/>
<classpathentry kind="lib"
path="/home/steven/iReport-1.3.1/lib/iReport.jar"/>
<classpathentry kind="lib"
path="/home/steven/iReport-1.3.1/lib/jcommon-1.0.0.jar"/>
<classpathentry kind="lib"
path="/home/steven/iReport-1.3.1/lib/jfreechart-1.0.0.jar"/ >
<classpathentry kind="lib"
path="/home/steven/iReport-1.3.1/lib/jsmoothgen-ant-0.9.7.jar "/>
<classpathentry kind="lib"
path="/home/steven/iReport-1.3.1/lib/looks-2.0-rc.jar"/>
<classpathentry kind="lib"
path="/home/steven/iReport-1.3.1/lib/png-encoder-1.5.jar"/ >
<classpathentry kind="output" path="bin"/>
</classpath>
------------------------------------------------------------ ----------
And this is the command I tried :
java -classpath bin:lib:/home/steven/iReport-1.3.1/lib GeneratePDF

GeneratePDF is in the bin subdirectory (GeneratePDF.class)

The result is :
Exception in thread "main" java.lang.NoClassDefFoundError:
net/sf/jasperreports/engine/JRException


???????????????????

Steven
Re: executing programs [message #205255 is a reply to message #205061] Mon, 16 April 2007 23:01 Go to previous message
Eclipse UserFriend
Originally posted by: reg.hill-labs.co.nz

Hi Steven,

I am pretty new at this game also...

However, looks like the xml classpath that you gave is Eclipse's class
path... when executing your app outside of Eclipse, I think that XML file
will be irrelevant.

Here is an example I use to create a PDF file using BIRT... should get you
started... It looks a bit long as I like to have each jar file on its own
line for readability...

Hope it helps.
Regarfds
Colin


-------------------------------
@Echo off
REM Creates a PDF file for all crop guides
REM Usage: CreatePDF.bat OutputFilePathAndName

set BIRT_HOME=C:\Java\AddIns\birt-runtime-2_1_1

REM set the birt class path, including DB drivers.
SET BIRTCLASSPATH=C:\Java\Addins\DBDrivers\jaybird-full-2.0.1.ja r
SET
BIRTCLASSPATH=%BIRTCLASSPATH%;%BIRT_HOME%\ReportEngine\lib\c ommons-cli-1.0.jar
SET
BIRTCLASSPATH=%BIRTCLASSPATH%;%BIRT_HOME%\ReportEngine\lib\c ommons-codec-1.3.jar
SET
BIRTCLASSPATH=%BIRTCLASSPATH%;%BIRT_HOME%\ReportEngine\lib\c om.ibm.icu_3.4.4.1.jar
SET BIRTCLASSPATH=%BIRTCLASSPATH%;%BIRT_HOME%\ReportEngine\lib\c oreapi.jar
SET BIRTCLASSPATH=%BIRTCLASSPATH%;%BIRT_HOME%\ReportEngine\lib\d teapi.jar
SET
BIRTCLASSPATH=%BIRTCLASSPATH%;%BIRT_HOME%\ReportEngine\lib\e ngineapi.jar
SET
BIRTCLASSPATH=%BIRTCLASSPATH%;%BIRT_HOME%\ReportEngine\lib\s criptapi.jar
SET BIRTCLASSPATH=%BIRTCLASSPATH%;%BIRT_HOME%\ReportEngine\lib\j s.jar
SET BIRTCLASSPATH=%BIRTCLASSPATH%;%BIRT_HOME%\ReportEngine\lib\m odelapi.jar
SET BIRTCLASSPATH=%BIRTCLASSPATH%;%BIRT_HOME%\ReportEngine\flute .jar
SET BIRTCLASSPATH=%BIRTCLASSPATH%;%BIRT_HOME%\ReportEngine\lib\s ac.jar
SET
BIRTCLASSPATH=%BIRTCLASSPATH%;%BIRT_HOME%\ReportEngine\lib\c hartengineapi.jar
SET
BIRTCLASSPATH=%BIRTCLASSPATH%;%BIRT_HOME%\ReportEngine\lib\o rg.eclipse.emf.ecore_2.2.0.v200606051102.jar
SET
BIRTCLASSPATH=%BIRTCLASSPATH%;%BIRT_HOME%\ReportEngine\lib\o rg.eclipse.emf.ecore.xmi_2.2.0.v200606051102.jar
SET
BIRTCLASSPATH=%BIRTCLASSPATH%;%BIRT_HOME%\ReportEngine\lib\o rg.eclipse.emf.common_2.2.0.v200606051102.jar

java -cp "%BIRTCLASSPATH%" -DBIRT_HOME="%BIRT_HOME%\ReportEngine"
org.eclipse.birt.report.engine.api.ReportRunner --format PDF --output %1
W:\EclipseWorkspace\CropGuide\src\CropGuide.rptdesign
Previous Topic:eclipse plugin path questions
Next Topic:setting the size of a view
Goto Forum:
  


Current Time: Fri Apr 26 10:07:06 GMT 2024

Powered by FUDForum. Page generated in 0.09254 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top