Imports (importing other java files)
Hi there. this is sorta urgent.
It works at uni, but not here, don't know why.
I am using JDK 1.4.1_01 and jcreater lite as an IDE
I have made a program, its for the course, but everytime I compile it says that the packages could not be found.
for example:
import Date.java;
import Calander.java;
public class mainapplication {
public static void main(String[] args)
..It gives me an error:
C:\coursework2\mainapplication.java:16: package Date does not exist
import Date.java;
^
C:\coursework2\mainapplication.java:17: package Calander does not exist
import Calander.java;
^
C:\coursework2\Date.java:15: package Calander does not exist
import Calander.java;
^
3 errors
And if I take out the .java; from the imports commands, then it still won't compile, saying it's expecting a '.'!
What should I do? I even tried going into MSDOS and typing javac mainapplication.java but i still get the same errors
Please help, I know it's a simple solution, but need your help.
Thanks
It works at uni, but not here, don't know why.
It does not work at uni, if you don't believe me go test it.
The "import" statement only gives you the option to use short names for classes. Thanks to it you don't need to type the fully qualified class name, such as "javax.security.auth.kerberos.KerberosKey", every time you want to use the class ("KerberosKey"). It only exists to help you, the programmer, write shorter code and type less.
That said, you cannot "import java files". It just makes no sense.
Date and Calendar are both in the package java.util, maybe you want to "import java.util.Date" and "import java.util.Calendar".
Hi there. this is sorta urgent.
I hate people who use that word...
Similar Messages
-
Can XML import other XML files?
Is it possible for a XML file to import other XML files? The idea is, to have several separate data in XML files and construct one big XML out of the many smaller XML files. Is there a "import" or "include" tag in XML?
xml files could be merged with the xslt document() function.
-
Hi,
I created a StockTablePanel.java file, and then compiled it fine.
Then, I wrote in a new file, StockTableTabPanel.java, the followings:
//top:
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
// Import our other components
import StockTablePanel;
(other code)
It failed in compile, and the error is:
'.' expected
import StockTablePanel;
^
What is the problem and its solution?
Thanks a lot.the correct syntax is:
import your.domain.name.projectname..StockTablePanel;and you also have to store your class StockTablePanel in this package:
package your.domain.name.projectname; //define package name for this class
public class StockTablePanel {
}See also the chapter "Packages" in the Java Language Specification: http://java.sun.com/docs/books/jls/second_edition/html/packages.doc.html#60384 -
How to run java source files from other java files??
hello all,
i need to run 3 to 4 .java files (first.java,second.java,third.java) from one file.
i tried the
Runtime.getRuntime().exec(cmd); but here cmd must be an exe file.
NOTE THAT i need to run the first.java file ,second.java file each time to generate their .class files(ie I NEED TO COMPILE THEM ALL TIMES AND THEN RUN THEM)
PLZ. help me if this can be done,
warm regards,
Vishal.One way to do this is to put all your commands into a batch file (this is Windows?) try unix shell otherwise. Anyway here's an example .bat file called cmplrun.bat:
@echo off
javac -classpath . TestCase*.java
java -cp . TestCase01
java -cp . TestCase02
java -cp . TestCase03Then the Java pgm can look like this:
import java.io.*;
public class RunProcess {
public static void main(String[] arg) {
try {
Process myProcess;
myProcess = Runtime.getRuntime().exec("cmd /c cmplrun");
String s = null;
DataInputStream in = new DataInputStream(
new BufferedInputStream(
myProcess.getInputStream()));
while ((s = in.readLine()) != null) {
System.out.println(s);
System.exit(0);
catch (IOException e) {
System.out.println("Exception: "+ e);
System.exit(-1);
}Just one way to do this, all caveats apply and HTH;
~Bill -
BUG: error rebuilding SQLJ files along other java files with generic
I have done a rebuild on a package containing some SQLJ files, and (consistently) got the following error:
C:\TeleMessage\trunk\src\telemessage\db\impl\dbAdmin.sqlj
Error(44,18): Java Parsing. Encountered: <
Expected: <IDENTIFIER> ...; "[" ...; The error at the cursor in the given file is not possible, since there was no '<' there, and besides - if I non-aggresively changed the file, e.g. narrowed imports, changed whitespace or added comments - the error remained in the same location.
I went and done a search using regex in the package, for a line starting with 17 chars followed by a '<'.
I found it in one of the normal JAVA files (not-SQLJ), at line 44 (surprise!) - in a Java 5 generics declaration, e.g. Map<String,Integer>. the 18th character was indeed the '<'.
I'm guessing that the SQLJ translator (accidentally?) parses non-SQLJ files.
If this cannot be fixed, it is really bad - it is one thing that JDeveloper cannot support Java 5 language features because of its dependancy in the SQLJ translator (which is not known to be upgraded until version 11g if at all), but the inability to compile SQLJ files in a project containing other non-SQLJ java files with Java 5 features is hard.
I could only workaround this by rebuilding SQLJ files one at a time!
I also have another type of error, when rebuilding the same project in a higher-level pacakge (root or "Application Sources"):
C:\TeleMessage\trunk\src\dbtools\CallbackNumberFiller.sqlj
Error(24,8): Missing semicolon.
Error(24,8): Unbalanced curly braces.Again, the specified file could not be the one to blame - the location of the error is in the middle of the public modified keyword in a method declaration; nothing is neither missing nor unbalanced.
This appears to be different, as it pops in the log near the end of the build process, when the JSPs are being built, specfically during the time the message log fills with "writing <...>" lines (after "translating <...>" and "compiling <...>".
I can consistently reproduce both cases - please advise how I can help you find out what causes this.
Regards,
Yaniv KundaFirst of all, this bug not JDeveloper's problem, but the SQLJ team's.
You can read more posts about this:
Re: BUG: Cannot translate SQLJ files with Java5 generics code
Re: How to use SQLJ with Java 1.4 and 1.5?
Re: SQLJ discontinued??
And if we're at it, this is strange - I can't seem to find the oracle doc you quoted...
SQLJ 11g? The latest release is a part of JPublisher 10.2 available from
http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html
I also didn't find anything on google on 11g, nor about the part number you specified.
Didn't find any Java 1.5 supporting SQLJ translators from other vendors as well.
Do you have any link to this statement?
But if we examine this bug again, the problem involves JDeveloper passing Java 5 featured JAVA files to the SQLJ translator.
Isn't there a way to instruct the translator to use CLASS files compiled by a normal Java 5 compiler, instead of trying to compile the files itself?
Regards,
Yaniv Kunda -
Is it possible to write a Java file that creates/compiles other Java files?
My goal is to write a program that writes files containing Java code depending on the user's input. That's the easy part. The tough part, I think, is to get the Java file to use the Java compiler to compile, and run, those newly created files.
I know this sounds crazy, but I really want to get this to work.
Can someone please tell me how to do this?You could use the eclipse compiler
http://help.eclipse.org/help31/index.jsp?topic=/org.ec
lipse.jdt.doc.isv/guide/jdt_api_compile.htm
Or the one from the JDK (com.sun.javac.Main located
in the JDKs /lib/tools.jar). But that won't work with
an JRE unless you ship the tools.jar too. And it
isn't what i would call an official API. So i would
rather use the eclipse compiler. I did this once and
it worked fine.it isn't what sun call an official API, either, which is somewhat more important! the license even used to restrict re-distribution of tools.jar (I think that's changed now) -
How to compile other java files and run them from my own programs?
I'm developing a unit testing tool for AspectJ, which can originally generate the stubs for aspect unit to be tested. All these stubs are java files. After generation of stubs, how can I program the code to compile this unit together with these stubs, i.e. how can I put the functionality of compilation and run, e.g. command "javac *.java" and "java *", into my own code.
Hope you can understand what I mean.
Thank you in advance.When I use Runtime.getRuntime().exec(command) for executing the AspectJ compile command "ajc", "IOException createProcess error=2" always occurs, while it is ok for Java comiple command "javac".
Why this happens when I use Runtime.getRuntime().exec("ajc Hello.java Test.aj")? Is it the reason that Runtime.exec(String) may not support any command in DOS?
(ajc is the compile command for the java file and aj file.)
Thank you in advance. -
Is it possible to compile & run other java files from one file
hi friends,
i need to run 2,3 java sourse files(first.java,second.java etc) from one file.i tried the Runtime.getRunTime().exec( cmd) but here cmd must be a executable file
what is need is to compile and run the files (first.java,second.java) from one other source file
pls. help me in this matter,
with warm regards,
VishalSure:public class Test {
public static void main(String[] args) {
try {
Runtime r = Runtime.getRuntime();
r.exec("javac Test2.java");
} catch (Exception e) {
public class Test2 {
public static void main(String[] args) {
System.out.println("Hello World!");
}Note that Test and Test2 are in two seperate files. -
ASK Access jList in other .java files
I'm using Netbeans.
I create new project, let's just say the name abc.
In project abc, I create a.java and b.java
There's jList in a.java, let's just say the name is jList1.
I use this code to add text to jList1
((DefaultListModel)jList1.getModel()).addElement("Sample text");In b.java, also got jList, let's just say the name is jList2
I run the program from a.java
I want to ask how to add text to jList2 located at b.java while I'm running a.java ?d_rev wrote:
I'm not really good in Java.
Can you please give me, just a simple code of what you mean to help me understand?No, not without seeing your whole program, which if it's a netbeans-generated program, no one here wants to see. The solution here is to get better at Java. Please have a look here: [http://java.sun.com/docs/books/tutorial/reallybigindex.html] -
Import tablesorter.java
Hello,
i'm a newbie and it is highly probable that it is easy for you. I will import some *.java-Files, but how can i do that?
Thanks,
Peterhi peter,
Go through this
/people/bertram.ganz/blog/2006/03/07/enhanced-web-dynpro-java-tablesorter-for-sap-netweaver-04s
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/60d5b593-ba83-2910-28a9-a7a7c7f5996f
Thanks&Regards
SureshKumar T -
JBuilder question on how to add a new .java file
I am new to Java and even newer to JBuilder. I am creating the GUI for our school project and my other members are creating the networking and database parts of our program seperatly. I am at the point were I need to import their .java files into my project I created in JBuilder.
Can someone tell me the steps I need to take to get those files into my project so I can start using the classes from my group they made up?
Thanks,
ScottYou can use show_alert statement and then make a check on button that is pressed from the alert.
Here is an example of show_alert built_in.
DECLARE
my_alert number;
ALERT_TXT VARCHAR2(200) := 'Do you want to delete record?';
BEGIN
set_alert_property('your_alert',ALERT_MESSAGE_TEXT,ALERT_TXT);
my_alert := show_alert('your_alert');
If my_alert = Alert_Button1 Then
/** I choose to delete record **/
-- here you can put your statements
else
-- I pressed NO button
-- here you can put your statements
end if;
END;Hope it helps you,
Fabrizio
If this answer is helpful or correct, please mark it. Thanks. -
Compiling java files in DOS window
Hi,
I have been writin a small Client Server Application. I am attempting to use java packages in order to put certain class files into particular directories, and then import the packages when needed.
So far, i have started my 1st attempt at a very small application just to send / receive messages. My problem is however, that i can compile all the java files into specific directories & packages no problem, but when i try to compile the java files which make use of these classes, i keep getting the same error.
OK, i will try to simplify,
My Server program (called MyServer.java) uses 2 classes (called ProcessTransaction, and NumberValidator), I have compiled the generated class files from ProcessTransaction.java and NumberValidator.java files into a DIR called C:\JavaForm\serverstuff. i.e. my server program imports the package "serverstuff,*;" The problem is that when i try to compile my server program i get the error message:
"cannot access ProcessTransaction
bad class file: c:\JavaForm\ProcessTransaction.java
file does not contain class ProcessTransaction
Please remove or make sure it appears in the correct subdirectory of classpath"
I am using the command:
javac -classpath c:\JavaForm c:\JavaForm\MyServer.java to compile the server file
All the java and class files are stored in the C:\JavaForm folder
I dont understand why the ProcessTransaction call cannot be accessed because it is most definitely in the compiled java file!!!
Any help would be much appreciated!!!
Cheers
Iainit's OK, i figured out that to compile the Server program successfully, you have to remove all the other java files from the DIR which the Server.java files exists, or else there is a conflict!!!! I dont know why, but that's what you have to do!!!!
-
Hi,
I need to call a java file when i click on the function(responsibility-->menu-->function) in EBS.
How?
Best Regards,
PalepuHi,
You have any oaframework page and from the link you want to call this java file,
or directly from the menu - function you want to call the java file.
In APPS normally there will not be any direct call to java file(.class), it will be called inside a OAFramework page file (click a link or button or inside some validation process)
or have a simple .jsp file and import the java file and use it in that .jsp file.
For the defn of .jsp file you can run the below query and get sample function defns.
select function_name, web_html_call from fnd_form_functions
where web_html_call like '%.jsp%' and web_html_call not like '%OA.jsp%'
Thanks,
With regards,
Kali.
OSSi. -
Compiling / Running a Java file in JSP
Hi,
ok, I have a jsp page, which we will call page 1. Once I go to that page, I all I want it to do is compile a certain file.java, and then run the file.java. The user doesn't actually know that this is going on in the background. Page 1 automatically redirects the user to page 2 (also a jsp page).
The java program that I created (that was previously compiled and ran) creates a special javascript file. After running the file.java in page #1, the java file creates a javascript file that will be used in page 2 to display a tree node (group of information).
so, right now, I'm trying to figure out how to write the jsp code that will tell how to compile and run a java file. I was thinking about using javabeans before, but I think you HAVE to actually display the contents of the java file into the jsp (I think). Anyhow, thanks for the help!sorry about being ambiguous before. What I mean by
running a java file was that I already created a java
file. I don't want to hava my java statements inside
the jsp file. I just want the jsp file have a command
in it that would call a java file, tell the java file
to compile and run. All the jsp file would do
(hopefully) is just give commands for a seperate java
file to compile and run. Thanks again for any help!Ok, so this other java file has some entry-point method, like main(), right? So call it...
<%
YourJavaClass.main(appropriateArgumentsGoHere);
%>
or better yet, it's an object you can use:
<%
YourJavaClass x = new YourJavaClass();
x.callSomeMethodHere(withAppropriateArgumentsHere);
x.callAnotherMethodMaybe();
%>
You don't need the jsp file to "compile" this java file, you'd already have compiled it beforehand, and it's class bytecode needs to be in your classpath (on the server side) of course. -
Converting a java file to a web service
How can i convert a java file to a web service,And then invoke that service by making my other java file.
You can convert your java file into a WSDL with the WSDL2Java utility in Axis. This will create a definition that will be accessible by potential clients.
To deploy your java class, you can use Axis in a Web Server of your choice (Tomcat, Apache). All you need to do is run the Axis Admin Client for a deploy.wsdd file and point your client to the IP:PORT.
Very straightforward.
http://ws.apache.org/axis/java/user-guide.html
Hope it helps.
SBO
Maybe you are looking for
-
Netmask is not set properly in Solaris 10
Hi, I am not able to change my netmask for bge0 NIC. I've just run Oracle CRS installer and it changed my netmask. I didn't install CRS. bash-3.00# ifconfig -a lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1 inet 12
-
File Adapter format translation problem
This is my incoming payload from a legacy application "66386","9002011319","01-FEB-2013","","2114.11","ITEM","0.12","","85411","2310","0","85","GST","68085" "66386","9002011319","01-FEB-2013","","2114.11","ITEM","15.00","","85411","2311","0","85","GS
-
How many pictures does a 30 GB ipod video hold?
how many pictures does a 30 GB ipod video hold? and i know it is probably somewhere on the website but i couldnt find it. could someone please answer me soon, thank you.
-
How do I reactivate DW CS5 which remains unresponsive?
Repeatedly, DW CS5 becomes unresponsive when I open it (on a MacBook Pro running OS 10.7.5). Been using the app daily for years without this happening previously. At startup, the DW page window on the left appears but is mostly blank; the directory/f
-
Trouble saving video files in premiere 13
Hello! I recently started recording gameplay with Nvidia Shadowplay at 1920x1080 with 30 and sometimes 60 fps. I import them into Adobe Premiere 13 as mp4 files, and after cutting them and adding music, I get some issues saving them. When I try to sa