Failed to compile J2EE source files
Hi all, I'm learning J2EE these days. When I followed the tutorials on how to compile source files,
eg. 1. In a terminal window, go to the j2eetutorial/examples directory.
2. Type the following command:
ant converter
I got a message with title "16 bit MS-DOS Subsystem" and content
"C:\WINDOWS\system32\ntvdm.exe
Error while setting up environment for the application. Choose 'Close' to terminate the application."
Could anyone tell me what's going on?
Thanks very much
The documentation on the javac command has information on the options it provides:
[http://java.sun.com/javase/6/docs/technotes/tools/windows/javac.html]
Otherwise you could use a tool like Ant to manage the build.
Similar Messages
-
Java.lang.NoClassDefFoundError when compile SQLJ source file
Always got error message java.lang.NoClassDefFoundError: sun/io/CharToByteConverter
when using sqlj to compile SQLJ source file.
The CLASSPATH (partial) .:$ORACLE_HOME/sqlj/lib/translator.zip:$ORACLE_HOME/sqlj/lib/runtime.zip
I am able to compile the demo TestInstallCreateTable.java and TestInstallJDBC.java but not TestInstallSQLJ.sqlj in the same directory.
I am using Oracle 8.1.6 R2 client in Linux Intel on Red Hat 6.0. Can anyone explain why this happened ?From the forthcoming new version of the SQLJ FAQ:
"NoClassDefFoundError: sun/io/CharToByteConverter"
(This is likely a general configuration issue, not something specific to your code.)
Running sqlj results in the following error message.
java.lang.NoClassDefFoundError: sun/io/CharToByteConverter
at sqlj.tools.Sqlj.initializeErrors(Sqlj.java:519)
This happens if you are running under a JRE environment, and not a full JDK environment. You need to download and install a full JDK environment. Note that the Oracle
database installation will only set up a Java Runtime Environment. Oracle does not distribute the Java Development Kit - you have to get it from http://java.sun.com
If that did not help, you'd need to give us a fuller picture of your environmnet (JDK versions, PATH, CLASSPATH settings, etc.).
Thanks! -
sorry, this is maybe a newbie question.
but iI have a problem compiling an application that use multiple sources files
for exemple
the class A is in the file 1
the class B is in the file 2
class A uses an instance of the class B
class B uses an instance of the class A
so i'm unable to compile these files coz each one tells me he doesn't know about the other
Is there a way to define prototypes of class or fonctions before their use like in C/C++?
Or is there another way i didn"t pay attention
thanks allThis is a minimal explanation of packages. For a full explanation of packages and how to compile and run Java programs, see this page:
http://java.sun.com/j2se/1.4.2/docs/tooldocs/tools.html
and read the Setting the Classpath and the How Classes are Found topics.
Assume that your programs are part of a package named myapp, which is specified by this first line in each source file:
package myapp;
Also assume that directory (C:\java\work\) is listed in the CLASSPATH list of directories.
Also assume that all your source files reside in this directory structure: C:\java\work\myapp\
Then a statement to compile your source file named aProgram.java is:
C:\java\work\>javac myapp\aProgram.java
And a statement to run the program is:
java myapp.aProgram
(This can be issued from any directory, as Java will search for the program, starting the search from the classpath directories.)
Explanation:
Compiling
A class is in a package if there is a package statement at the top of the class.
The source file needs to be in a subdirectory structure. The subdirectory structure must match the package statement. The top subdirectory must be in the classpath directory.
So, you generate a directory structure C:\java\work\myapp\ which is the [classpath directory + the package subdirectory structure], and place aProgram.java in it.
Then from the classpath directory (C:\java\work\) use the command: javac myapp\aProgram.java
Running
Compiling creates a file, aProgram.class in the myapp directory.
(The following is where people tend to get lost.)
The correct name now, as far as java is concerned, is the combination of package name and class name: myapp.aProgram (note I omit the .class) If you don't use this name, java will complain that it can't find the class.
To run a class that's NOT part of a package, you use the command: java SomeFile (assuming that SomeFile.class is in a directory that's listed in the classpath)
To run a class that IS part of a package, you use the command java myapp.aProgram (Note that this is analogous to the command for a class not in a package, you just use the fully qualified name) -
StackOverflowException compiling 8000 source file
I am trying to compile a source file with ~8000 lines. It has many (hundreds) of static members (instances of that class), and methods containing conditional statements to take a string and return the instance of that name. This is generated code, so I do not think I can change it.
Every time I try to compile it with Maven (Sun JDK 1.4.2_05) I get a java.lang.StackOverflowException. I have tried giving Maven more stack memory via the -Xss option (as much as 10m per thread), but that didn't help at all.
I commented out 90% of the code and it works fine, so I know it is the size that is the problem.
Has anyone had to deal with something like this before? If so, how did you fix it?Thank you to everyone who has replied. After some experimentation I discovered that the problem is not the 800+ static objects being created - it was the 1000's of lines of nested conditional statements. The generator has been modified to make if, if, if... instead of if, else-if, else-if, ... and all is well. :)
I do not believe any sort of hard limit was reached, b/c Eclipse had no problem with the file. Also, one of our projects has a source file with 12k lines, and it works fine (though it has a different structure).
I find it interesting that people are being so critical about the generator, especially since this is only one small piece of its modelling. The generator does far more than just create the key types and values.
Furthermore, I don't understand the criticism of the code as-is. No, it's not something I'd write myself, nor would I wish to maintain such code - but no one has to! That's what the generator is for. If I want to add or delete a key type/value, I do so in the generator, and then regenerate the code.
I also don't understand why anyone thinks this code is not object-oriented. Perhaps I just didn't explain it well. All classes representing key types extend AbstractDiscreteValue, so there's inheritance. The reason why all the values exist as static (and final) instances is b/c we never need more than one instance of each value, the values are known at generation time, and all instances are immutable.
How would any of you construct such a class? Keep in mind that maintenance is not an issue, and most key types (probably 95% or more) have fewer than a dozen values.
Anyway, thanks again for the help. -
Stuck with compiling a source file
Hi,
I'm stuck with this strange problem and i desperately need some help.
My source file is in the D drive inside the package named objectwrite. The source file X.java is extending an abstract class named Y. When i'm trying to compile the files using the command javac objectwrite\ x.java y.java from D drive, it's giving the follopwing error
javac: invalid flag: ObjectWrite/
Looking forward for the solution
Thnks
Rompom_1You have a space between '\' and 'x'
-
The command oracg fails to generate Java source files
I tried to use the command 'oracg -schema Openshipments.xdr' to generate Java source files from
XML schema file Openshipments.xdr . Although the schema file is valid, the command oracg fails with following error messages :
file:/D:/romel/project/UPS/doc/Openshipments.xdr<Line 6, Column 47>:
XSD-2026: (Error) Invalid attribute 'name' in element 'element'
file:/D:/romel/project/UPS/doc/Openshipments.xdr<Line 6, Column 47>:
XSD-2030: (Error) Element 'schema' has invalid namespace:
'urn:schemas-microsoft-com:xml-data'
file:/D:/romel/project/UPS/doc/Openshipments.xdr<Line 6, Column 47>:
XSD-2027: (Error) Invalid element 'ElementType' in 'schema'
file:/D:/romel/project/UPS/doc/Openshipments.xdr<Line 6, Column 47>:
XSD-2027: (Error) Invalid element 'ElementType' in
'schema'file:/D:/romel/project/UPS/doc/Openshipments.xdr<Line 6, Column
47>: XSD-2027: (Error) Invalid element 'ElementType' in 'schema'
file:/D:/romel/project/UPS/doc/Openshipments.xdr<Line 6, Column 47>:
XSD-2027: (Error) Invalid element 'ElementType' in 'schema'
file:/D:/romel/project/UPS/doc/Openshipments.xdr<Line 6, Column 47>:
XSD-2027: (Error) Invalid element 'ElementType' in 'schema'
file:/D:/romel/project/UPS/doc/Openshipments.xdr<Line 6, Column 47>:
XSD-2027: (Error) Invalid element 'ElementType' in
'schema'file:/D:/romel/project/UPS/doc/Openshipments.xdr<Line 6, Column
47>: XSD-2027: (Error) Invalid element 'ElementType' in 'schema'
file:/D:/romel/project/UPS/doc/Openshipments.xdr<Line 6, Column 47>:
XSD-2027: (Error) Invalid element 'ElementType' in 'schema'
...... the above line is repeated many times
Error: Schema Class Generator failed to generate classes.
oracle.xml.parser.schema.XSDException: Invalid attribute 'name' in
element 'element'Your schema is not a valid XML Schema. Please check up with the syntax.
Thanks. -
i just learn about java. but i find that i fail to open the java source that i had download from the net. do i need addition software to open it? if i had installed the jbuilder already?
You should be able to open any .java file in Wordpad or Notepad. JBuilder just makes the code look pretty.
-
I cannot compile "C" source file on Mac OS X(10.8.2)
Hi,
I am trying to compile the C source filein terminal, using "cc" or "gcc" command. No luck.
Later on, tried to ran the command, xcrun cc filename.c, the compiler gave an error about header files.I have tried with /bin/cc and /usr/bin/cc and tried to find the "CC" command or "gcc" command or "C++" or "g++" command in the directories. No luck!
echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
I have checked the cc binaries in all of the above directories. No luck -
Error when compiling the J2ee tutorial source files
HI,
I have installed ant, j2ee tomcat-3.2.2 and jdk1.3 and when i tried to compile the source file downloaded from java.sun by
ant converter, it prompted
"Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/main"
I am running it on win98 with the autoexec.bat containing the followings:
set J2EE_HOME=c:\j2sdkee1.3
set JAVA_HOME=c:\jdk1.3.1
set ANT_HOME=c:\jakarta-ant-1.3
set TOMCAT_HOME=c:\tomcat\jakarta-tomcat-3.2.2
set classpath=;.;c:\jdk1.3.1\jre\lib\rt.jar;c:\j2sdkee1.3\lib\j2ee.jar;c:\jaxp\xalan.jar;c:\jaxp\crimson.jar;c:\jaxp\jaxp.jar;c:\C:\jakarta-ant-1.3\lib\ant.jar;C:\jakarta-ant-1.3\lib\jaxp.jar;C:\jakarta-ant-1.3\lib\parser.jar
PATH=%PATH%;"C:\Program Files\Mts";C:\PROGRA~1\ULTRAE~1;c:\jdk1.3.1\bin;c:\j2sdkee1.3\bin;c:\jakarta-ant-1.3\bin;C:\PROGRA~1\MICROS~4\80\TOOLS\BINN
Really thx for help !!!!Hi.
I am compiling the sample converter.ear downloaded from
the j2ee tutorial bundle form java.sun. I am using jakarta-ant-1.4alpha-bin.zip downloaded from jakarta
oh..yes it should be org.apache.tools.ant.Main ....sorryfor typo.....
look forward to any helpful reply -
Problem compiling source file in package
Hi, I have 5 source files which I have just packaged together and put in the same sub-directory, the problem is that when I try to compile the file with the main method I get the error message:"cannot read" then the name of the source file. I am compiling from the command line and setting the classpath as I compile with the statement:
c:\j2sdk1.4.1\bin>javac -classpath c:\directory\package directory source file.java
I'm not sure what I am doing wrong and the source files all compiled fine before I added the package statement to the files. Please any help would really be appreciated.It sounds like the java file your are trying to compile is not in the directory you are compiling from.
Is this basically what you are doing?:
Say the package name is mypackage.
Assume we are O.K. with keeping source and class files together.
Create a directory named 'mypackage' somewhere...C:\mypackage\.
Put all the .java files in it (these .java files indicate that they are a member of the 'mypackage' package).
At a command prompt, cd to the directory containing the 'mypackage' directory...'cd C:\'
Compile the source files: C:\j2sdk1.4.1\bin\javac mypackage\*.java
run the main class: C:\j2sdk1.4.1\bin\java mypackage.TheMainClass
Basically, this says keep the files where you want them and point to javac, instead of moving everything under java/bin. btw it will save a lot of typing if you add java/bin to your PATH.
Hope this helps. -
Compile source files from multiple subdirectories
Hi. we know that we can compile multiple source files in a folder with the statement:
javac -classpath . *.java
How can we compile multiple source files that belong to different subfolders without using an IDE?
Example:
folder1, folder2, & folder3 all have .java source files, and all 3 folders belong to a folder named bigfolder;
what is the shortest way to compile those source files in one statement like the one above?It should work withjavac -classpath your_classpath folder1\*.java folder2\*.java folder3\*.javaJust make sure that your_classpath allows all of the classes to be found.
It might be better to use the -d option in your case.javac -d path_for_classes folder1\*.java folder2\*.java folder3\*.javaYou just specify the directory into which the .class files and their package directories should go. -
Do we have to separate java source files and class files after compiled..
Hi,
I really confussed with this:
I have compiled java source files into a package and tried to use but the classes can not be found. Should I separate class and source files after compiled with packages names. I hope you understand what i mean.
Thank you
So JagYou can choose to separate the source files or not. It sounds like your problem has to do with Classpath and packages.
If the file c:\base\compute\engine\mysourcefile.java starts with the statement "package engine;" then the fully qualified name of the class is is engine.mysourcefile. If the file c:\base\compute\client\mysourcefile.java starts with the statement "package client;" then its fully qualified name is client.mysourcefile.
In your source files, whenever you refer to a class from another class, the compiler needs the fully qualified class name. You can either import the class or use the fully qualified name. In order for the compiler to find the class, the c:\base\compute directory must be in the Classpath (assuming the package definitions from above).
Finally, to launch an application given the above, the command would be "java client.mysourcefile" assuming the main method is in client.mysourcefile. -
Compiling source files in directory separate from JDK
I'm trying to switch from Visual Cafe to a more agnostic platform: just using a text editor and then compiling and running with Sun's JDK. The problem is that I can't actually get my programs to compile and produce class files. I suspect a Classpath or directory structure problem, but I don't know how to attack this.
I am running Windows 2000, and the JDK is sitting at C:\j2sdk1.4.0_01. I'm keeping my source files at in a separate directory at E:\New_Java_Files. When I try to compile a source file in this directory, I don't get the resulting class files even though it compiles (that is, javac does not give any errors). On the other hand, when I compile the "Hello World" app in this same directory, it does produce a class file and then I can run it.
Any suggestions?
Thanks, YaoIf javac is actually running, and you don't tell it to stick your files somewhere else, it should create .class files in the same directory as the .java ones.
My guess:
Since javac succeeds, either the .class files end up in some other location, or you're somehow compiling a different version of your file in a different location. Try searching for any instances of yourclass.class -
I've sucesfully compiled java source files (*.java files) over a lot of different encodings (ANSI, Unicode, UTF8, etc). My IDE (Eclipse) has Cp1252 as default on WIndows OS.
There is an 'official' encoding for source files ?Short answer is Unicode -but that's not enough.
From Java Language Specification:
"Except for comments (�3.7), identifiers, and the contents of character and string literals (�3.10.4, �3.10.5), all input elements (�3.5) in a program are formed only from ASCII characters (or Unicode escapes (�3.3) which result in ASCII characters). ASCII (ANSI X3.4) is the American Standard Code for Information Interchange. The first 128 characters of the Unicode character encoding are the ASCII characters."
There's more that applies, I'll not quote it, read chapter 3 of JLS for details.
http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html -
Activation of the activity fails u0096 no source files in the active workspace
Dear All,
Im working on a NWDI installation since last month. The NWDI server (NW2004s) has been installed and configured with the following parameters:
Some Details:
- Java Stack on SPS 12
- No complete Developer Workplace, we only use the Studio (SPS 12)
- OS: WIN 2003
- DB: Oracle 10g
- SDK: 2 SDK, Standard Edition x64 1.4.2_15
Installation Usages Types: DI, AS Java, EP Core, EP (EP for the Visual Composer)
Performed configuration steps:
- adaptation of VM parameter in the Visual Admin
- patched the NWDI Server and the Studio from SPS 9 to support package stack 12 + available single patches
- run the template installer => NWA with type DI Allinone run all post installation Steps for DI, CBS, CMS, DTR
- Oracle Parameters changed, User and Authorizations created and assigned (UME, J2EE Security roles, DTR => ACL List), SLD (Creation of a new Landscape), Configuration of the CBS with the VA
- Configuration of the Studio (SAP J2EE Engine (fill in the NWDI engine), Proxy Settings, Development Configuration Pool)
Development Steps for an example:
- Creation of a new software product (SLD)
- Namespace reservation on SLD => Application Context Root, Development Component Name
- Created a Domain and a Track on CMS
- Attached all Software components to the track (my own dc, SAP-JEE, SAP_Buildt, SAP_JTechs)
- Check-In the Software Components on Transport studio => CMS
- Moved the development configuration into Studio
- Created a ear- and a web-project => Display a JSP File (Its the same example like in the SAP Course TADM10)
- Check-in the activity under Open activities => Activate
My problem appears during the check-in phase in the studio. I was able to check-In the source files in to the inactive Workspace on the DTR, but the activation of the activity fails. (I thought that the build process runs automatically after the activation - also the movement from the source files from the inactive to the active workspace?).
I received no error message, but I cant find any source files in active workspace. The activity seems to be pending. I locate the request in the CBS, the request state is failed regarding the request type activate.
At the moment there is no separate runtime system assigned to the NWDI System.
Questions:
1. Have I forgotten an important configuration step?
2. Can I use the NWDI Server also as a runtime environment (DEV System)?
Please let me know if somebody has an idea.
Thanks.
ChristophHello Michael,
thanks a lot for your answer.
I found the following error messages in the <b>request log</b>:
<i>Calculate all combinations of components and variants to be built...
"xxxtest.com/math/calc/webdc01" variant "default"
"xxxtest.com/math/calc/webdc01" variant "default" cannot be built. Activation will fail.
INVALID dependency is declared to public part: default.
[DC 247 variant "default"][SC 65 "xxxtest.com_TASCHENRECHNER_1"] using [PP default of DC 6 at Build-Time Dependency]
"xxxtest.com/math/calc/eardc03" variant "default"
"xxxtest.com/math/calc/eardc03" variant "default" cannot be built. Activation will fail.
The required Build Plugin "sap.com/tc/bi/bp/enterpriseApplication/enterpriseApplication" IS UNKNOWN. None of the compatments contains a suitable plugin for this component.
[DC 248 variant "default"][SC 65 "sanofitest.com_TASCHENRECHNER_1"] using [BP sap.com/tc/bi/bp/enterpriseApplication/enterpriseApplication]
Prepare build environment in the file system... started at 2007-09-04 06:13:54.316 GMT
Prepare build environment in the file system... finished at 2007-09-04 06:13:54.316 GMT and took 0 ms
===== Pre-Processing ===== finished at 2007-09-04 06:13:54.332 GMT and took 406 ms
Change request state from PROCESSING to FAILED
ERROR! The following problem(s) occurred during request processing:
ERROR! The following error occurred during request processing:Activation failed due to component "xxxtest.com/math/calc/webdc01" variant "default". The component is BROKEN.
ERROR! The following error occurred during request processing:Activation failed due to component "xxxtest.com/math/calc/eardc03" variant "default". The component is BROKEN.
REQUEST PROCESSING finished at 2007-09-04 06:13:54.332 GMT and took 422 ms</i>
The <b>Build Log</b> was empty.
Thank you in advance.
Best regards
Christoph
Maybe you are looking for
-
How do I add Microsoft Outlook on my bookmark toolbar so I can go directly to it?
I'd like to open Microsoft Outlook emails directly from Firefox (like I can in IE). How do I create a bookmark for Outlook to place on the bookmark toolbar?
-
Hello all, My friend has typed his essay on iWork for iCloud on a PC, and then he upgraded his account to iCloud Drive, and he has no access to his essay anymore since it says that because you're account is upgraded you cannot access your files on iW
-
Motion in a Black Screen Mode that Won't Esc
I have tried Fn F8, Esc, Cmd-, etc., but I can't navigate away from this full screen mode in motion. At least I htink I am in full screen mode. I have quit the progam and relaunched, and for a split second after the relaunch the other areas of the pr
-
Can't get application id "com.apple.ScreenSaver.Engine".
I'm trying to compile the following in AppleScript Editor in OS X 10.6.4 and keep getting the following error message: Can't get application id "com.apple.ScreenSaver.Engine". Any suggestions? try tell application id "com.apple.ScreenSaver.Engine" to
-
Default Cost Centre No. in the Settlement Rule
We have an issue here. When maintenance orders are settled, a Cost centre ABCD001 is automatically picked up as 'settlemement receiver'. From where this default Cost Centre number is coming ? Could you please guide me.