Running a java program in a directory other than the current directory
How do I run a java program that's located in a directory other than the current directory?
There is a file Test.java in /dir1/subdir1. If my current directory is anywhere other than that directory, say /dir2/subdir2, I can compile Test.java by using:
javac -classpath /dir1/subdir1 /dir1/subdir1/Test.java
But when I try to run it with:
java -classpath /dir1/subdir1 /dir1/subdir1/Test
I get a java.lang.NoClassDefFoundError: \dir1\subdir1\Test
Any thoughts?
You need to specify just the name of the class you want to run. So java -classpath /dir1/subdir1 Test
Similar Messages
-
Rsync - download to directory other than the sync directory
I want to rsync from server/dir to local/dir. local/dir is an outdated sync of server/dir. I would like to perform a sync but actually download the necessary files for the sync to a different directory than local/dir.
Basically: compare server/dir and local/dir, download the necessary updates to local/some-other-dir.
It doesn't seem as if rsync has this functionality built in, but it's possible I'm missing something.
How could I do this?My question is more complex than a standard backup procedure, I don't see anything about my question in the wiki.
Basically, I compare A to B but actually perform the backup to location C. -
Anyone know how I can get an audio file imported into my iTunes' podcast directory, rather than the music directory?
I downloaded a series of podcasts recently. They were imported into my "music" directory instead, making it more difficult for me to recall where I left off with the last podcast I listened to before having to stop it for whatever reason. Thanks in advance for any help.You can do it, though the result isn't ideal. Import your episode, then select it in the Music list and hit command-i to bring up the info panel:
However each episode you do this with will turn up as a 'podcast' with no name - and it doesn't seem possible to give it one - containing the one episode: -
I start running a java program and when i switch users the sound doesnt work
When I start running a java program or leave a game running and i switch users the sound doesnt work. I have been searching around the web and nobody seems to have an answer. This just recently started to happen. Please if anyone has any ideas that would be much appreciated and the problem is my computer its almost brand new. And my computer is completely up to date.
Sony Mobile team has a separate community which can be found here.
If my post answers your question, please click on "Accept as Solution" -
Java always returns 15 minutes greater than the current time.
Hi,
I am using Microsoft Windows Server 2003R2,Standard X64 edition with Service Pack 2 and jdk1.6.0-03.
Java always returns time 15 minutes greater than the current system time.
eg:
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println("Now time: "+simpleDateFormat.format(new Date()));
System.out.println("Now time: "+new Date());The output of the program is :
Now time: 2008-12-22 18:47:04
Now time: Mon Dec 22 18:47:04 NPT 2008
When my actual system time is 6:32 PM or (18:32)
I have checked the current time with other programming languages like python and it always returns the actual date and time.
Note: To my observation java is always utilizing a time which is 15 minutes greater than the current time even for its log.
Thanks,
Rajeswari (Msys)I think a more practical time machine would be one that actually travels back in time rather than forward (by 15 minutes). Sounds like it needs some more work.
Anyway, I suggest changing the system time on your computer to some other value (say, 2 hours ahead), then running the program again. If its off by 2 hours and 15 minutes, its getting the time from your computer. However, if its still off by only 15 minutes (from your wristwatch's time), then its getting the time form somehere other than the computer clock. -
How to enable remote debugging for a session other than the current one
Hi all,
I am trying to figure out how to enable remote debugging for a session other than the one I am currently using.
More specifically, we have an application that is making database calls to Oracle 11gR2. Something is causing an exception during this invocation. My system is currently not set up to recompile said application, so I can't just add the debug call to the code and recompile. Therefore I would like to be able to log into the database (as sys, if necessary) and invoke dbms_debug_jdwp.connect_tcp on the desired session.
The docs indicate that I should be able to do so:
dbms_debug_jdwp.connect_tcp(
host IN VARCHAR2,
port IN VARCHAR2,
session_id IN PLS_INTEGER := NULL,
session_serial IN PLS_INTEGER := NULL,
debug_role IN VARCHAR2 := NULL,
debug_role_pwd IN VARCHAR2 := NULL,
option_flags IN PLS_INTEGER := 0,
extensions_cmd_set IN PLS_INTEGER := 128);
But when I try (even as sys), I get the following:
exec dbms_debug_jdwp.connect_tcp('1.2.3.4',5678,<session id>,<session serial>);ORA-00022: invalid session ID; access denied
ORA-06512: at "SYS.DBMS_DEBUG_JDWP", line 68
ORA-06512: at line 1
00022. 00000 - "invalid session ID; access denied"
*Cause: Either the session specified does not exist or the caller
does not have the privilege to access it.
*Action: Specify a valid session ID that you have privilege to access,
that is either you own it or you have the CHANGE_USER privilege.
I've tried granting the 'BECOME USER' privilege for the relevant users, but that didn't help. I read something about having to set some kind of ACL as of 11gR1, but the reference documentation was very confusing.
Would someone be able to point me in the right direction? Is this even possible, or did I misread the documentation?Interesting deduction, that would be very useful indeed. I hate recompiling just to add the debug call, and it can't be done in our production environment. But it seems unlikely to me it would be implemented this way.
I would cross-post this in the SQL AND PL/SQL forum though, as this is really a database issue, not with the SQL Developer tool. Do add the links to the other posts in each.
Regards,
K. -
Making jar file in folder other than the working directory
Hello!
I am trying to make jar files by using a program. I execute jar commands at runtime. The problem is that when a command is given like this
jar cvmf C:\HTTPS\Manifest.txt C:\HTTPS\khalid.jar C:\HTTPS\client.cer
C:\HTTPS\Client.jar C:\HTTPS\client.keys C:\HTTPS\HelloRunnableWorld.class C:\HT
TPS\HelloRunnableWorld.java C:\HTTPS\keytool interaction commands.txt C:\HTTPS\M
akeJarRunnable.class C:\HTTPS\MakeJarRunnable.java C:\HTTPS\MakeJarRunnable.zip
C:\HTTPS\Manifest.txt C:\HTTPS\myjar.jar C:\HTTPS\myjar_r.jar C:\HTTPS\Problem s
cenario.txt C:\HTTPS\Run.bat C:\HTTPS\scompressed.jar C:\HTTPS\Security.jar C:\H
TTPS\Server.jar C:\HTTPS\server.keys C:\HTTPS\serverexport.cer C:\HTTPS\Starter.
class C:\HTTPS\Starter.java C:\HTTPS\Umer Farooq - What I did.ppt C:\HTTPS\Umer.jar
The jar file is created but it has 0 bytes in it. No data is written into it, despite all the files being there.
Thank YouThat is not the way to create jar files. Here is how you do it.
Under say c:\ create directory "utils".
Copy all of the *.java" files which will be part of this jar file "utils.jar". After moving files into c:\utils , make sure every single file has the first line of code as "package utils;" (without the quotes though)
Type in "javac *.java" to compile all of the files at once.
cd over to the parent directory and then type in
jar cvf utils.jar c:\utils\*.class
This will create utils.jar file under c:\ -
Getting Menu Reference for a VI other than the current one
Is there any way to get a Menu reference for a VI that isn't the current VI? There's Current VI's Menubar, but that only works on the current VI. I'd like something that does the same thing, but accepts a VI reference to a higher-level VI. I would expect to find a Property Node entry for it, but there doesn't seem to be one. This is for 8.2.
eaolson wrote:
A functional global is what I wound up using. It just seems odd to me that there's no other way to get access to that reference.
It also seems counter-intuitive to me that a Shortcut Menu reference is only valid inside that particular frame of the Event Structure that caught it. If you're using a producer-consumer architecture, you can not send that refnum off to the consumer loop for handling; it can only used within that frame of the Event Structure.
I am not sure what you mean. The refnum seems to be accessible from everywhere .
As i wrote above:
You can store the Menu Reference to a global variable for example, and you can read it, in any vi you want, just like all variables.
Note: Do not try to use a property note. Use the menu functions -
Tomcat won't compile jsps if they are in any directory other than root
I'm running a new instance of Tomcat, and can't get a simple jsp file to compile, if it's in any directory other than the root.
The jsp is:
<%@ page import="test.Simple" %>
<%@ page contentType="text/html" language="java" %>
<html>
<body><%=Simple.makeText()%>
</body>
</html>
and the Simple class is:
package test;
import java.util.Random;
public class Simple {
public static String makeText() {
return String.valueOf(new Random().nextInt());
When I place the jsp in the root directory, it works fine.
When I place the jsp in any subfolder (eg: /debug/1b.jsp), I get the following error:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
Generated servlet error:
Only a type can be imported. test.Simple resolves to a package
An error occurred at line: 14 in the jsp file: /1b.jsp
Generated servlet error:
Simple cannot be resolved
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
org.apache.jasper.JasperException: Unable to compile class for JSP
Generated servlet error:
Only a type can be imported. test.Simple resolves to a package
An error occurred at line: 14 in the jsp file: /1b.jsp
Generated servlet error:
Simple cannot be resolved
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
Here's the server info:
Server version: Apache Tomcat/5.5.25
Server built: Sep 24 2007 11:31:18
Server number: 5.5.25.0
OS Name: Linux
OS Version: 2.6.20.20-071008a
Architecture: amd64
JVM Version: 1.5.0_10-b03
JVM Vendor: Sun Microsystems Inc.
Using fedora core 6.
I looked into the Tomcat work directory, and it looked as if the jsp was successfully converted to a java file. I'm not sure where to look, as all the settings are defaults.
Any help is greatly appreciated. Thanks:D :D :D...
My friend it'd be great idea if you can find google tutorial on TOMCAT/web application basics
anyways coming back to your problem
whenever,an application is deployed on tomcat a new folder is being created at the following location %CATILINA_HOME%/webapp/ with respect to application name.
Therefore try to maintain an architecture like the one below if you programmin any web application.
%CATILINA_HOME%/webapp/<applicationName>/(place all your .jsp files)
-----------------%CATILINA_HOME%/webapp/<applicationName>/META_INF/(Place your mainfest files & context specific configuration files)
-----------------%CATILINA_HOME%/webapp/<applicationName>/WEB_INF/ (Genrally used to save secured files which cannot be access directly and always make sure you prepare a web.xml file associated to the application)
-----------------%CATILINA_HOME%/webapp/<applicationName>/WEB_INF/lib (place where all your .jar file libraries are being placed)
-----------------%CATILINA_HOME%/webapp/<applicationName>/WEB_INF/classes (place where all your .class,resource files are being placed as the pacakage structure you have choosed in)
If this doesnot work even if you ensuring everything's right.Reading through tutorials & speding time on finding resources by yourself would be a great idea.
I hope there are no hard issue on this. :)
REGARDS,
RaHuL -
How to upgrade to something other than the most recent OS
I am currently running Os 10.6.8. I would like to update, but I have a critical application that is only qualified for 10.8.2 and the current operating system is 10.8.4. Is there a way to buy something other than the current OS?
Apple updates the OS X installer at the Mac App Store with the latest version, and older OS X versions disappear. If you want to upgrade to Mountain Lion and you purchase Mountain Lion at the App Store, you will get the OS X Mountain Lion installer with 10.8.4 installed, so it will install 10.8.4, without any possibility to install 10.8.2.
You can try changing system files to look like you are using 10.8.1 and try applying the 10.8.2 update, but doing this you may damage OS X Mountain Lion -
URGENT: How to run a Java program from a different directory?
Hi.
How do I run a Java program from a directory that the file is not located in? So lets say im in c:\Java. But the file is in c:\Java\abc\efg\.
What would be the command to run the Java file from c:\Java.
I can't remember it and I need it asap.
Cheers.If the class you are trying to run is MyApp.class, try
c:\Java\>java -cp abc\efg MyAppThe actual classpath you specify will depend on whether or not MyApp.class is in a package (I've assumed it isn't) and whether or not any 3rd party jars are involbed (I've assumed not).
Edited by: pbrockway2 on Apr 1, 2008 6:42 PM
The command arguments read as "Run the MyApp class using as a classpath abc\efg relative to here (c:\Java)". -
How do i run a java program an another directory?
How do I run a java program that's in a different directory?
I have been doing this in the command line:
java "C:\Document and Settings\freeOn\Desktop\Java\Test\test"
and I get
Exception in thread "main" java.lang.NoClassDefFoundError:
C:\Document and Settings\freeOn\Desktop\Java\Test\test
I just thought there might be a quick way to do this and not
have to cd to the following dir evertime i want to run an app in
console.
The test.java file is this:
import java.io.*;
public class test {
public static void main(String args[]) {
System.out.println("Testing.....");Ok I looked in the java help and found the classpath, this makes it alittle easier.
java -cp C:\DOCUME~1\freeOn\Desktop\Java\Test\ test
At least i can run this in the run dialog which makes it easier thanks for you help kota balaji -
Running a java program via a batch file
I am unable to run a java program from a batch file that I created.
spiderpackage.EntryPoint is a class file which I am trying to run with a -v option to output something.What should I do to get the output?
echo ^<html^>^<body^>
echo hello^<br^>
call java spiderpackage.EntryPoint -v
echo ^</body^>^</html^>This has nothing to do with java programming. Have a look at the windows help for the call command.
The echo <html> stuff doesn't make sense. What's it for?
The command in you batch file should be:
java -cp . spiderpackage.EntryPoint -v
assuming that java is in the system path, and the EntryPoint.class is in a directory called spiderpackage which is a subdirectory of your current working directory -
Running a Java program at startup in Linux
Hello
How do I run a Java program at startup in Linux? I know in Windows I can put a .bat file in C:\Windows\Start Menu\Programs\StartUp\ directory, but in Linux I have no idea how it is done.
Thank you,
MihaiThis is really a Linux question, not Java.
And then it depends on the version of Linux you are using.
Maybe this will help, otherwise you should try on a forum for your version of Linux. -
Using a UNIX shell script to run a Java program (packaged in a JAR)
Hi,
I have an application (very small) that connects to our database. It needs to run in our UNIX environment so I've been working on a shell script to set the class path and call the JAR file. I'm not making a lot of progress on my own. I've attached the KSH (korn shell script) file code.
Thanks in advance to anyone who knows how to set the class path and / or call the JAR file.
loggedinuser="$(whoami)"
CFG_DIR="`dirname $0`"
EXIT_STATUS=${SUCCESS}
export PATH=/opt/java1.3/bin:$PATH
OLDDIR="`pwd`"
cd $PLCS_ROOT_DIR
java -classpath $
EXIT_STATUS=$?
cd $OLDDIR
echo $EXIT_STATUS
exit $EXIT_STATUSHi,
I have an application (very small) that connects to
our database. It needs to run in our UNIX environment
so I've been working on a shell script to set the
class path and call the JAR file.
#!/bin/sh
exec /your/path/to/java -cp your:class:paths:here -MoreJvmOptionsHere your.package.and.YourClass "$@"Store this is a file of any name, e.g. yuckiduck, and then change the persmissions to executechmod a+x yuckiduckThe exec makes sure the shell used to run the script does not hang around until that java program finishes. While this is only a minor thing, it is nevertheless infinite waste, because it does use some resources but the return on that investment is 0.
CFG_DIR="`dirname $0`"You would like to fetch the directory of the installation out of $0. This breaks as soon as someone makes a (soft) link in some other directory to this script and calls it by its soft linked name. Your best bet if you don't know a lot of script programming is to hardcode CFG_DIR.
OLDDIR="`pwd`"
cd $PLCS_ROOT_DIRVery bad technique in UNIX. UNIX supports the notion of a "current directory". If your user calls this program in a certain directory, you should assume that (s)he does this on purpose. Making your application dependent on a start in a certain directory ignores the very helpful concept of 'current directory' and is therefore a bug.
cd $OLDDIRThis has no effect at all because it only affects the next two lines of code and nothing else. These two lines, however, don't depend on the current directory. In particular this (as the cd above) does not change the current directory for the interactive shell your user is working in.
echo $EXIT_STATUS
exit $EXIT_STATUSEchoing the exit status is an interesting idea, but if you don't do this for a very specific purpose, I recommend not to do this for the simple reason that no other UNIX program does it.
Harald.
Maybe you are looking for
-
Hello guys, I'm kind of new to the forum as I managed to buy this model N560GTX-M2D1GD5 recently. So ...the card works perfectly...I have installed the latest drivers and games are performing very well, but there is a small problem I encountered when
-
Help with recording microphone
I there I have a audigy 4 pro (and cubase le instaled in my computer) and i have some questions to make: Is it possible to record two microfones at the same time?how? Why the level when im using line in 1(micro)/2/3 and record an audio track in cubas
-
Dependant Validation Type in General Ledger
Can we make use of Dependant Validation Type in General Ledger, the need arises because we have 2 segments States and Branches. Now the Branches are dependant based on the States. So can I make use of Dependant Validation Type. Since Oracle recommend
-
How to display PDF BLOB file within Forms
Hi All: I just want to know if is it possible to display PDF blob file within the forms. Currently I use webutil to open pdf in browser. This time I need to display it in forms, so that upon scrolling, the user can view the pdf images of that particu
-
Automate uninstalling JRE 7 update 60 x586 and x64 on the same device
Hi we have a large number of devices on our estate that have both the x64 and x586 versions of Java installed on them. I want to uninstall both versions but there only appears to be one uninstall key under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Window